Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chat without refreshing or IRC server??

Status
Not open for further replies.

apatterno

Programmer
Nov 26, 2002
368
US
It seems like all the PHP chat scripts are limited in that they have to keep refreshing the page all the time, or else they rely on additional server processes and (which many hosting providers do not allow).

I thought of a method that doesn't require a server process running continuously in the background, nor do clients have to refresh every 2 seconds to check for updates.

Imagine this process, a simple chat between 3 people (A, B and C).

A, B and C are each waiting for someone to talk. So they each send a request to listen.php on the web server, which starts three instances of listen.php running. Each instance of listen.php creates a FIFO and opens it for reading, which blocks execution. And the chatters await their replies.

Meanwhile, Person A decieds to send a message. So A's browser issues a request to talk.php, which writes to the FIFOs created by the instances of listen.php. This wakes up the instances of listen.php, which return the contents of the message to the clients who are listening.

The process repeats with all the clients requesting listen.php again, meaning that they are ready to listen for more messages.

I haven't implemented this yet. It seems too hard. I would appreciate if someone told me whether or not I am insane for thinking this could work.

Also, any ideas on overcoming the "maximum script execution time" barrier?

Thanks
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top