AJAX instant Messenger
Moderator: General Moderators
AJAX instant Messenger
I am looking for a technique to implement an AJAX instant messenger. I understand that polling makes it possible, but if you look at say gmail and facebook instant messengers they seem to be, well, instant. I have tested it with two computers and I see no noticeable delay. I'm guessing that is considered a comet implementation, but I can't seem to see how it can be done. At least with php. I have tried it with ASP.NET and was able to do it with threading, however you can't thread with php. So am I missing something obvious? How is this being done? Especially since facebook uses php.
Re: AJAX instant Messenger
You could keep the HTTP connection opened and wait something to "happen" (by using sleep() in a loop). If nothing "happens" then close the connection just before the timeout.
There are 10 types of people in this world, those who understand binary and those who don't
Re: AJAX instant Messenger
wouldn't spinning like that be a huge a resource hog? sleep() pauses the thread itself I'm guessing?
Re: AJAX instant Messenger
While it's CPU friendly, it's not so Apache friendly (there is a limit of the maximum number of Apache spawned child processes)Omego2K wrote:wouldn't spinning like that be a huge a resource hog? sleep() pauses the thread itself I'm guessing?
So, if you are going to serve many and many clients don't use it, use AJAX instead.
But if you are going to use it for just a few clients (i.e. Intranet WWW application) it's better to use this approach.
There are 10 types of people in this world, those who understand binary and those who don't
Re: AJAX instant Messenger
so what's the best server to use to accomplish this, on windows specifically? IIS?