0

I've searched Google a lot. In all the examples having Comet with PHP and jQuery. They are doing:

setTimeout(function(){ check_new_data_function() }, 5000); 

function check_new_data_function(){
    $.ajax{
    blah
    }
}

And yes, it's pretty simple to use Comet with checks in every 5 seconds. But this could not be called "COMET" at all, isn't the purpose of Comet to not loop our requests? and instead get the data which is Pushed from server?

See this example. Or another clip. They are all having a function which gets the data from another file with $.ajax requests by looping. But are they really Long Polling/Comet?

As far as I knew when we didn't want to put the server under many $.ajax request which are looped, we would use Comet, in Comet the data is gonna Pushed from server to the client browser, was I wrong?

Could someone make this idea clear for me?

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
behz4d
  • 1,819
  • 5
  • 35
  • 59
  • Well, first come down. `:P` Browsers don't yet broadly support web sockets. So long polling is preferred. You do see libraries that incorporate web sockets, though, and use them if they are available. – Jared Farrish Dec 31 '12 at 11:31
  • @JaredFarrish is there any difference between Long Polling and Comet? and would you give some example on other libraries? how facebook and twitter are implementing their own Comet? – behz4d Dec 31 '12 at 11:33
  • Comet is an interface through a socket; it's *push*, so comet means *it tells you when you have [whatever]*. Long polling is leaving a request open long enough to shorten the distance between the messenger and receiver, but the receiver (the client) has to initiate the request. – Jared Farrish Dec 31 '12 at 11:39

1 Answers1

1

Can I Use on Web Sockets - Working Draft:


Partial support refers to the websockets implementation using an older version of the protocol and/or the implementation being disabled by default (due to security issues with the older protocol). Microsoft is currently experimenting with the technology.

enter image description here

https://i.stack.imgur.com/7nRwm.png

The technology just isn't there yet. Watch this video from SymfonyLive if you want a better grasp on what the specs for HTTP and REST mean. It's interesting, and apparently Twitter goofed.

Also see:

http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
  • 1
    then how Facebook and Twitter are using their Comet? are they looping their requests? the answer would be definitely no if you asked me, because that would be a complete mess! – behz4d Dec 31 '12 at 11:36
  • Some browsers support it, and so does iOS and most programming languages. I imagine that's why Facebook's app on the iPhone is a native app now, so they could abandon the web's stateless polling situation. – Jared Farrish Dec 31 '12 at 11:41
  • 1
    Facebook use HTTP long-polling. Whilst Comet techniques will be around for a while still WebSockets are the best solution for realtime bi-directional communication between a web client and a web server. More info on [Comet v WebSockets here](http://www.leggetter.co.uk/2012/04/22/websockets-realise-comet-theyre-not-an-alternative.html) – leggetter Jan 01 '13 at 15:12