WebSocket Class
The WebSocket class allows applications to send and receive data after the WebSocket upgrade has completed.
System.Net.WebSockets.WebSocket
System.Net.WebSockets.ClientWebSocket
System.Web.WebSockets.AspNetWebSocket
Namespace: System.Net.WebSockets
Assembly: System (in System.dll)
The WebSocket type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CloseStatus | Indicates the reason why the remote endpoint initiated the close handshake. |
![]() | CloseStatusDescription | Allows the remote endpoint to describe the reason why the connection was closed. |
![]() ![]() | DefaultKeepAliveInterval | Gets the default WebSocket protocol keep-alive interval in milliseconds. |
![]() | State | Returns the current state of the WebSocket connection. |
![]() | SubProtocol | The subprotocol that was negotiated during the opening handshake. |
| Name | Description | |
|---|---|---|
![]() | Abort | Aborts the WebSocket connection and cancels any pending IO operations. |
![]() | CloseAsync | Closes the WebSocket connection as an asynchronous operation using the close handshake defined in the WebSocket protocol specification section 7. |
![]() | CloseOutputAsync | Initiates or completes the close handshake defined in the WebSocket protocol specification section 7. |
![]() ![]() | CreateClientBuffer | Create client buffers to use with this WebSocket instance. |
![]() ![]() | CreateClientWebSocket | This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.Allows callers to create a client side WebSocket class which will use the WSPC for framing purposes. |
![]() ![]() | CreateServerBuffer | Creates a WebSocket server buffer. |
![]() | Dispose | Used to clean up unmanaged resources for ASP.NET and self-hosted implementations. |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | IsApplicationTargeting45 | Obsolete. Returns a value that indicates if the WebSocket instance is targeting .NET Framework 4.5. |
![]() ![]() | IsStateTerminal | Returns a value that indicates if the state of the WebSocket instance is closed or aborted. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ReceiveAsync | Receives data from the WebSocket connection asynchronously. |
![]() ![]() | RegisterPrefixes | This API supports the .NET Framework infrastructure and is not intended to be used directly from your code. Allows callers to register prefixes for WebSocket requests (ws and wss). |
![]() | SendAsync | Sends data over the WebSocket connection asynchronously. |
![]() ![]() | ThrowOnInvalidState | Verifies that the connection is in an expected state. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Some of the classes in the System.Net.WebSockets namespace are supported on Windows 7, Windows Vista SP2, and Windows Server 2008. However, the only public implementations of client and server WebSockets are supported on Windows 8 and Windows Server 2012. The classes and class elements in the System.Net.WebSockets namespace that are supported on Windows 7, Windows Vista SP2, and Windows Server 2008 are abstract classes. This allows an application developer to inherit and extend these abstract classes with an actual implementation of client WebSockets.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



