Forum Moderators: open
I've used the technique when running very complex long-lived server processes, when I wanted a progress meter. Your server process could be a huge SQL operation, a crawler indexing pages, mashing up APIs, or just a really long loop... anything that takes a long time to complete, thus holding the HTTP connection open.
How it works is really simple. Let your server script go do what it wants. And every once in a while, you "flush()" some content.
in PHP:
print("one");
flush();
$i=100000000000000;while($i>0){$i--}; // wait a long time
print("two");
flush();
$i=100000000000000;while($i>0){$i--}; // wait a long time
print("<script>alert('hi there!')</script>");
flush();
In the server-side script, define certain events, times, or milestones at which you will flush() content to the client.
I'm very skeptical of how well this would scale. I certainly wouldn't try anything like this on a publicly-accessible website - I'm pretty sure my server would barf. Yet if developers are going to begin dusting this old technique off, optimizing machines that can handle it, and making applications that use it responsibly, I'm already intrigued.
I don't know if I can get used to calling it "COMET".