1
votes

My understanding of Comet is that its a server-side AJAX request. My understanding of Long Polling ("Push") is that it is also a server-side AJAX request. My understanding of WebSockets is that they are a two-way AJAX request.

If any of these are wrong, please begin by correcting me!

Assuming I'm more or less correct, is it true that these are all just AJAX (JavaScript using XmlHttpRequest object under the hood)? If they are not all just AJAX calls, then how do you implement them in the client (via JavaScript) and on the server (using something like Java)? Thanks in advance!

1
Not necessarily. You could use iframes.scottheckel
WebSocket is a solid two-way connection between client and server, there is no requests (Apart from initial handshake) - you just send data and get data directly. This scales much better than having to make a new request for every message.Esailija
Regarding the terminology part of your question, you can check-out this answer: stackoverflow.com/questions/10782058/… As for the two-way aspects of Comet and WebSockets, check out the final part of this article: cometdaily.com/2011/07/06/…Alessandro Alinone

1 Answers

2
votes

Your understanding of WebSockets is incorrect. WebSockets is a new protocol and provides a new API that has nothing to do with XmlHttpRequest.

This is how you create a WebSocket

var exampleSocket = new WebSocket(
    "ws://www.example.com/socketserver", "protocolOne"
);  

See https://developer.mozilla.org/en/WebSockets/