views:

431

answers:

4

I am implementing a system where I need real-time updates. I have been looking at certain scenarios and among all was Comet. Implementing this I do not see any way this is different from traditional long-polling.

In both cases you have to send a request, and then the server send a response back. In the browser you interpret the response and then you start a new request.

So why should I use comet if in both cases I need to open and close connections.

+3  A: 

Comet is an umbrella term for a wide range of asynchronous update techniques, of which long-polling is just one.

Marcelo Cantos
Ok i understand this. But there is a comet plugin for jquery, which can be used with a comet server. What benefits does this have over traditional long-polling. I can not find any recourses where something else is used other than long-polling.
Saif Bechan
+4  A: 

Some Comet techniques don't require that you constantly open new requests (the chunked hidden iframe, for instance), the idea being to hold the request open and have the server periodically sending data. But this doesn't work well across all major browsers without (as one Wikipedia contributor delicately put it) negative side-effects, hence the long-polling technique. More in the linked article.

T.J. Crowder
This is what I thought. Because in this secion http://en.wikipedia.org/wiki/Comet_(programming)#Streaming it looks like a streaming connection is something comet can do. But i am searching trough every single example found on the net and can not find a single working streaming connection.
Saif Bechan
+1, also see http://cometdaily.com/2007/12/18/latency-long-polling-vs-forever-frame/ and http://cometdaily.com/2007/11/16/more-on-long-polling/ to note that there's really no practical difference between long-polling and the "forever frame" idea.
jvenema
+3  A: 

As mentioned by Marcelo, Comet is usually used to describe any techniques for "HTTP streaming", including long-polling. In some cases, Comet might also refer more specifically to the Bayeux Protocol. For instance, the jQuery Comet plugin is of this protocol. From the Bayeux website:

Delivery of asynchronous messages from the server to a web client is often described as server-push. The combination of server push techniques with an Ajax web application has been called Comet. CometD is a project by the Dojo Foundation to provide multiple implementation of the Bayeux protocol in several programming languages.

Bayeux is an attempt to standardize a publish/subscribe protocol using Comet techniques, allowing for vendors of client and server side libraries to create interoperable components.

Jørn Schou-Rode
Can you achieve http streaming with jQuery Comet. Thus with only one request and multiple responses. I see many websites that refer to the theoretical technique, but I can not find a tiny example app
Saif Bechan
One request with multiple response should be possible using an `<iframe>` as transfer media. I am not sure if the jQuery plugin supports this optional part of the Bayeux protocol.
Jørn Schou-Rode
+1, this deserves more votes than my answer.
Marcelo Cantos
A: 

If you want to push insteal of pulling, you can use JPE.

xavierm02