NOTE Answering to popular demand expressed in comments to this thread, we are now making a .NET prototype implementation of a WebSocket draft specification available for download. Check out the details at http://tomasz.janczuk.org/2010/12/websockets-wcf-service-silverlight-and.html.
One of the HTML 5 initiatives is to define a duplex communication protocol called WebSocket for use between web browsers and servers. The protocol enables a number of applications that must exchange messages between the client and the server with performance characteristics that cannot be met with the HTTP protocol. In particular, the protocol enables the server to send messages to the client at any time after the WebSocket connection has been established and without the HTTP protocol overhead. This contrasts WebSocket to technologies based on the HTTP long polling mechanism available today.
A sample web chat application built using a prototype implementation of the WebSocket protocol is available at http://40interop.ep.interop.msftlabs.com/html5/wschat.html, as well as hosted in Windows Azure at http://websockets.cloudapp.net/wsdemo.html. The prototype consists of the following components:
- The server side of the WebSocket protocol implemented using Windows Communication Foundation (WCF) from .NET Framework 4. The endpoint at ws://40interop.ep.interop.msftlabs.com:4502/servicemodelsamples/chat.svc implements two currently considered protocol proposals: the draft-ietf-hybi-thewebsocketprotocol-00 (also referred to as version 76), and draft-hixie-thewebsocketprotocol-75. The server implementation automatically detects the version the client is using.
The client side of the WebSocket protocol implementation consists of two components:
- A Silverlight 4 application that implements the draft-hixie-thewebsocketprotocol-75 version of the WebSocket protocol. It is available at http://40interop.ep.interop.msftlabs.com/html5/ClientBin/Microsoft.ServiceModel.Websockets.xap.
Given the approach taken, the sample chat application based on WebSockets should be working in all major browsers (Internet Explorer, Firefox, Chrome, Safari, Opera).
Mike Taulty has an excellent post explaining in more detail the client side implementation.