HTML5 WebSockets Client for .NET

So, I found that amazing thing called HTML5 WebSockets, new API. That is still in DRAFT version, but quite well supported. Full-duplex bi-directional communication. I know how to use it via JavaScript, there is APIs. But if I want to use a WebSocket client within my C#/.NET application, how to do that?

For example JavaScript: http://bohuco.net/blog/2010/07/html5-websockets-example/

Are there are any special client libraries for WebSockets in .NET?


Solution 1:

sir SuperWebSocket include a WebSocket server implementation and a WebSocket client implementation. SuperWebSocket's project page

Solution 2:

I've recently done some research into this whilst building a .NET and Silverlight client library for Pusher. I found the following WebSocket client libraries and projects:

  • Microsoft WebSocket client prototype
  • SuperWebSocket note: there is a client in there, it's just difficult to find
  • WebSocket-Sharp
  • Anaida

For the moment the Microsoft implementation is probably the easiest to use and it also has a Silverlight library. SuperWebSockets has a Silverlight project in the source but not in the latest drop.

Solution 3:

Starting from .NET 4.5, WebSocket clients are supported via System.Net.WebSockets.ClientWebSocket

You can browse or download this sample C# app from MSDN Code website: http://code.msdn.microsoft.com/WebSockets-middle-tier-5b2972ce/sourcecode.

To the down-voters of the question, the sample is mainly focused on connecting to WebSocket services, which is another significant use-case for a network-centric C# application.