System.Net.WebSockets.WebSocketProtocol
5.1.0
Prefix Reserved
See the version list below for details.
dotnet add package System.Net.WebSockets.WebSocketProtocol --version 5.1.0
NuGet\Install-Package System.Net.WebSockets.WebSocketProtocol -Version 5.1.0
<PackageReference Include="System.Net.WebSockets.WebSocketProtocol" Version="5.1.0" />
paket add System.Net.WebSockets.WebSocketProtocol --version 5.1.0
#r "nuget: System.Net.WebSockets.WebSocketProtocol, 5.1.0"
// Install System.Net.WebSockets.WebSocketProtocol as a Cake Addin #addin nuget:?package=System.Net.WebSockets.WebSocketProtocol&version=5.1.0 // Install System.Net.WebSockets.WebSocketProtocol as a Cake Tool #tool nuget:?package=System.Net.WebSockets.WebSocketProtocol&version=5.1.0
About
Provides the WebSocketProtocol
class, which allows creating a WebSocket
from a connected stream using WebSocketsProtocol.CreateFromConnectedStream
.
NOTE: This package was designed as a temporary solution for internal use (building ASP.NET targeting .NET Standard 2.0), and is now considered obsolete. If targeting .NET Standard 2.1 or .NET 5+, use WebSocket.CreateFromStream
instead.
Key Features
- Creates a new
WebSocket
instance that operates on the specified transport stream. TheWebSocket
class allows applications to send and receive data after theWebSocket
upgrade has completed. - The API can be used to create both client-side and server-side
WebSocket
instances.
How to Use
To create a WebSocket
using WebSocketProtocol
, as a prerequisite, you need to prepare the opaque transport stream for the WebSocket, for example, create or accept a TCP socket connection as a Stream
and perform a WebSocket opening handshake (upgrade) over it. Then you can use the transport stream and the negotiated subprotocol to call WebSocketProtocol.CreateFromStream
.
Stream opaqueTransport = /* ... */; // complete WebSocket opening handshake over the transport connection
WebSocket ws = WebSocketProtocol.CreateFromStream(opaqueTransport, isServer: true, subProtocol, keepAliveInterval);
Remarks
The API is considered obsolete and is not recommented for use.
On .NET Framework or .NET Standard 2.0:
- To create a client
WebSocket
from a stream, useWebSocket.CreateClientWebSocket
.- Alternatively, consider using a
ClientWebSocket
class.
- Alternatively, consider using a
- Creating a server
WebSocket
from a stream is not available on the API surface, consider usingHttpListener
or ASP.NETHttpContext
to accept server WebSocket connections.
On .NET Core 2.1+, .NET 5+ or .NET Standard 2.1:
- To create a client or server
WebSocket
from a stream, useWebSocket.CreateFromStream
Main Types
The main types provided by this library are:
- System.Net.WebSockets.WebSocketProtocol
Additional Documentation
- API reference can be found in: https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.websocketprotocol
- Additional APIs mentioned:
- WebSocket static methods: https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.websocket
- ClientWebSocket: https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket
- HttpListener context: https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistenercontext
- ASP.NET HttpContext: https://learn.microsoft.com/en-us/dotnet/api/system.web.httpcontext
License
System.Net.WebSockets.WebSocketProtocol is released as open source under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Buffers (>= 4.6.0)
- System.Memory (>= 4.6.0)
- System.Numerics.Vectors (>= 4.6.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.0)
- System.Threading.Tasks.Extensions (>= 4.6.0)
-
.NETStandard 2.0
- System.Buffers (>= 4.6.0)
- System.Memory (>= 4.6.0)
- System.Numerics.Vectors (>= 4.6.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.0)
- System.Threading.Tasks.Extensions (>= 4.6.0)
-
net6.0
- No dependencies.
NuGet packages (5)
Showing the top 5 NuGet packages that depend on System.Net.WebSockets.WebSocketProtocol:
Package | Downloads |
---|---|
Microsoft.AspNetCore.WebSockets
ASP.NET Core web socket middleware for use on top of opaque servers. This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/0f9ad16b096ca2535d77efd2ad27645449421b44 |
|
Microsoft.Azure.SignalR
.NET Standard SDK for Azure SignalR. |
|
Microsoft.Azure.SignalR.Management
Provides communication capabilities with ASP.NET Core SignalR clients through Azure SignalR Service directly. The capabilities include sending messages to all/clients/users/groups and managing group membership. For more information, see https://github.com/Azure/azure-signalr/blob/dev/docs/management-sdk-guide.md |
|
MixinCSharpSdk
Mixin C# SDK is a high performance sdk for mixin. Include Mixin network api, messager api and websocket api. |
|
SocketFlow.Server
Server of event-oriented network library |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on System.Net.WebSockets.WebSocketProtocol:
Repository | Stars |
---|---|
Azure/azure-signalr
Azure SignalR Service SDK for .NET
|
|
aspnet/WebSockets
[Archived] Implementation of the WebSocket protocol, along with client and server integration components.
|