Streaming HTTP

I’m interested in writing a little chat server and game arranger to run on my server. This will be used to allow players to chat before playing and decide who they want to play with. I don’t really want to run a bespoke process on the server (or rather I though I’d try something different this time) and was wondering if I could maybe create a PHP script that streamed out of a “chat” file. Then have my Java client come in and stream the PHP output down into the chat window. Likewise pushing chat messages up would be done via a script which just added on to the end of the chat file.

Does anyone know if this streaming works?

Kev

The lazy way is to just use plain-old HTTP requests :slight_smile: and poll…any reason why not?

Really, I just don’t want to have the delay associated with polling mechanisms.

Kev

Right. Usually, people set these up with a 2 second poll, which turns out to be more than enough in most cases.

Bear in mind that there’s an in-built latency of 1-5 seconds for people to type their entire sentence anyway, even with IRC (part of why it’s so much slower to talk over IRC than over the phone). So, the poll delay is only doubling the existing latency (whereas if you just naively looked at trasmit latency of 100 ms or so, it would seem to be having a much greater effect.).

And webservers can stream files at a 2-secc poll to a VERY large number of clients simultaneously :).

Even better, if you want to be clever and cool and efficient, use XMLHTTPRequest to only fetch the additional chatlines since last fetch, and transparently add them to the page, and give them a new colour, etc.