1

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!

4

1 回答 1

2

你的理解WebSockets是不正确的。WebSockets 是一种新协议,提供了一个与XmlHttpRequest.

这就是创建 WebSocket 的方式

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

请参阅https://developer.mozilla.org/en/WebSockets/

于 2012-07-06T22:14:20.223 回答