Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused by Microsoft WebSockets namespaces

So far, in tutorials, blogs, and official documentation, I've seen:

  • Microsoft.Web.WebSockets
    • Obtained from NuGet
    • The assembly is Microsoft.WebSockets, but the Namespace is Microsoft.Web.WebSockets
    • Last updated 14 Sept 2011
    • Contains WebSocketHandler, WebSocketCollections, WebSocketExtensions
  • System.Web.WebSockets
    • Part of .NET 4.5 and available in Visual Studio 11 Developer Preview
    • Contains AspNetWebSocket, AspNetWebSocketContext, AspNetWebSocketOptions classes
    • Documentation on MSDN
  • System.Net.WebSockets
    • Thanks Ladislav Mrnka for pointing this one out
    • Part of .NET 4.5 and available in Visual Studio 11 Developer Preview
    • Contains WebSocket, HttpListenerWebSocketContext and more
    • Documentation on MSDN
  • System.ServiceModel.WebSockets
    • I must have imagined I'd seen this one somewhere, can't find it now
  • Microsoft.ServiceModel.WebSockets
    • Obtained from html5labs.interoperabilitybridges.com/....
    • Installed into [Program Files]\Microsoft SDKs\WCF WebSockets\11.06.22\bin
    • Contains WebSocketHost, WebSocketService, WebSocketsService classes, plus interfaces and collections
    • Last updated 22 June 2011

are these somehow different? Are some older versions?

I've always assumed the 'Microsoft.Web' namespace was used for pre-release code, but even the demos at the Build conference use this namespace, despite the fact that .NET 4.5 includes the System.Web.WebSockets namespace built in.

System.Web.WebSockets seems to have the same API as Microsoft.Web.WebSockets, but with classes and methods prefixed with AspNet.

System.ServiceModel.WebSockets is part of the WCF namespace, which also seems a sensible place to put this stuff.

Help - I'm confused. What should I be using?

like image 478
Greg Woods Avatar asked Oct 24 '11 12:10

Greg Woods


2 Answers

I will add little bit more to your confusion. Microsoft.* prefixed assemblies / namespaces are usually either very specific to some language or not part of .NET framework (shipped out of band (or prototypes)).

Assemblies / namespaces shipped with .NET framework usually start with System.*. There are two namespaces containing features related to WebSockets in .NET 4.5:

  • System.Net.WebSockets - implementation of WebSockets
  • System.Web.WebSockets - integration of WebSockets with ASP.NET

I haven't see System.ServiceModel.WebSockets but I think there was some prototype named Microsoft.ServiceModel.WebSockets

like image 189
Ladislav Mrnka Avatar answered Oct 06 '22 01:10

Ladislav Mrnka


html5labs.interoperabilitybridges.com:

...we don't plan any future updates to this prototype.

System.Web.WebSockets:

...namespace contains classes that support adding WebSocket functionality to ASP.NET Web Forms applications.

Microsoft.Web.WebSockets:

...provides functionality for writing WebSocket-enabled server applications on Windows 8 using ASP.NET and WCF


My conclusion:

  • System.Net.WebSockets seems like something low-level.
  • System.Web.WebSockets need when you use ASP.NET Web Forms
  • Microsoft.Web.WebSockets from NuGet looks like best choice when you use ASP.NET MVC
like image 34
resnyanskiy Avatar answered Oct 06 '22 01:10

resnyanskiy