18

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.

Saif Bechan
  • 16,551
  • 23
  • 83
  • 125
  • 1
    READ THIS: http://cometdaily.com/2007/12/11/the-future-of-comet-part-1-comet-today/ – Prisoner ZERO Aug 16 '12 at 18:20
  • The above (excellent) link is dead. Wayback Machine has it [here](https://web.archive.org/web/20180313110255/http://cometdaily.com/2007/12/11/the-future-of-comet-part-1-comet-today/). – Ben Aston May 18 '20 at 12:06

4 Answers4

12

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
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • 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 Apr 03 '10 at 10:03
  • +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. – Jerod Venema Apr 04 '10 at 18:03
11

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
  • 37,718
  • 15
  • 88
  • 122
  • 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 Apr 03 '10 at 10:24
  • One request with multiple response should be possible using an ` – Jørn Schou-Rode Apr 03 '10 at 10:51
7

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

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
  • 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 Apr 03 '10 at 09:57
0

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

xavierm02
  • 8,457
  • 1
  • 20
  • 24