WebSockets protocol vs HTTP

1) Why is the WebSockets protocol better? WebSockets is better for situations that involve low-latency communication especially for low latency for client to server messages. For server to client data you can get fairly low latency using long-held connections and chunked transfer. However, this doesn’t help with client to server latency which requires a new … Read more

Using comet with PHP?

Agreeing/expanding what has already been said, I don’t think FastCGI will solve the problem. Apache Each request into Apache will use one worker thread until the request completes, which may be a long time for COMET requests. This article on Ajaxian mentions using COMET on Apache, and that it is difficult. The problem isn’t specific … Read more

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

In the examples below the client is the browser and the server is the webserver hosting the website. Before you can understand these technologies, you have to understand classic HTTP web traffic first. Regular HTTP: A client requests a webpage from a server. The server calculates the response The server sends the response to the … Read more

How do I implement basic “Long Polling”?

It’s simpler than I initially thought.. Basically you have a page that does nothing, until the data you want to send is available (say, a new message arrives). Here is a really basic example, which sends a simple string after 2-10 seconds. 1 in 3 chance of returning an error 404 (to show error handling … Read more