Creating a Socket Server using Coldfusion
<p>I want to notify my iPhone app of updates using a socket server for real time updates and to prevent the need for polling. My server side language is Coldfusion, and after weeks of searching the web following threads of people attempting to do this the conclusion everyone has come up with is that Coldfusion doesn't support this. Firstly if anyone has any suggestions that no one else has provided as to what is the proper way to do this with Coldfusion then feel free to cut me short and please enlighten me. Anyhow, a solution occurred to me (in my sleep!) and before I invest my time doing this I wanted to ask if it is critically flawed for any reason.</p>

<p>There isn't anything in the adminstrator that supports this, and people rightly point out that you can't instantiate a server socket on the page since it will hang the page waiting for requests, and that then the server will then be destroyed when the page times out.</p>

<p>But what is wrong with the following solution, I create my AppServer.cfc component, which essentially wraps a java ServerSocket. Then to trigger it run this:</p>

<pre><code>&lt;CFSET APPLICATION.servercfm=new AppServer()&gt;

&lt;CFTHREAD timeout="2147483647"&gt;
    &lt;CFSET APPLICATION.servercfm.start()&gt;
&lt;/CFTHREAD&gt;
</code></pre>

<p>The server then remains indefinately on the APPLICATION scope, and the page returns instantly. The thread timeout is sets to 60 years, although I'm sure that I'll have more frequent server restarts!</p>

<p>I hope this question isn't flagged as opinionated, my question is: is there ANY means, by which we can provide a service through a socket using Coldfusion whether it be my solution or any suggested by the forum.</p>

<p>Thanks</p>