0

I'm starting to learn about web sockets as a faster alternative to some of my ajax calls. I've noted my IIS6 server doesnt support web sockets. Is there a way around this by getting a client side web socket to simulate an ajax call to the server?

1 Answers1

2

Ajax and Web Sockets both allow the client to push information to the server. Web Sockets, however, are superior in their ability to allow the server to push data to the client without the client asking for it.

Suppose you are playing an online Chess game in your browser, and you waiting for your opponent to make a move. With traditional Ajax, you'd have to repeatedly ping the server (or use long-polling, see the link below) to ask if your opponent has made a new move. With Web Sockets, the server can tell you about the move as soon as it happens, without having to constantly ask.

There are techniques to allow Ajax to exhibit some of the advantages of Web Sockets. This class of techniques is known generally as "Comet".

To address your question specifically: if your server does not support Web Sockets, you will have to try using Comet techniques to optimize Ajax for server-push delivery of data. There is no way to use Web Sockets on your client without a Web Socket server to communicate with.

apsillers
  • 112,806
  • 17
  • 235
  • 239
  • I've long been using various forms of comet techniques. Just wondering if a web socket can be used to simulate and retrieve a standard call to a page. (ie. http on port 80) – user1416526 May 25 '12 at 04:57
  • No, it cannot. In fact, I think the Web Socket protocol was designed specifically to prevent this from being possible, since an HTTP port can be extended to also receive Web Scoket requests, so it must be able to tell the difference. – apsillers May 25 '12 at 05:21