Here is a quick explanation of what is going on behind the scene:

When a client loads the HTML page, a Javascript function is triggered. This
function performs an Ajax call to the server. In the case of Stuart, I
think he wrote a small fastCgi script that does trap this call (instead of
forwarding the call to PHP I Guess).
The server does not respond directly. Instead, it does not respond
directly, but it keeps the connection to the browser open. 

When someone else types something in the form, an Ajax call is performed to
the server. The fastcgi script receives this message, and sends the message
on all the open connections.

This technique is known as "Comet".

You can find a more detailed explanation here:

If you want to do the same, there are several options:
1- You do it yourself, like Stuart did. Believe me, this is painful,
especially when you want compatibility with old browsers like IE 6, since
involves a lot of Javascript
2- You use a Javascript framework + a light server: Orbited
( and Meteor-server ( can help
you do such a thing. You can also google for the "Bayeux" protocol that is
standardised implementation of Comet. I think Dojo
( implements it (not sure though)
3- You use a server side framework that will write Javascript for you.
There are several such frameworks in Java. In PHP, the only one I am aware
of is Xaja (
4- You decide to use Flash instead, or a framework that use Flash
underneath (
5- You wait for HTML 5 that might, someday (2012?), provide a direct way to
do this  ;)


On Tue, 21 Apr 2009 10:42:54 -0400, tedd <> wrote:
> At 3:27 PM +0100 4/21/09, Stuart wrote:
>>2009/4/21 tedd <>:
>>  > That's about it, isn't it?
>>You know me better than that ;-)
>>It's a live chat system with no flash in sight. No DB either, the
>>whole thing is stored in Memcached.
>>When you post a message it should take no longer than a second to get
>>to all other people present. On the server-side it has a tiny
>>footprint of less than 2MB per 20 concurrent users.
> -Stuart:
> Yeah, I figured that you would complicate matters considerably. ;-)
> And there you go again talking about stuff I'm clueless about.
> Okay, so we all can agree it's a form, right?
> And visitors can enter stuff, right?
> So what happens then? Please give me an outline of what happens and 
> use short words.
> Cheers,
> tedd
> -- 
> -------

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to