Export (0) Print
Expand All

WebSocket Class

.NET Framework 4.5

The WebSocket class allows applications to send and receive data after the WebSocket upgrade has completed.

Namespace:  System.Net.WebSockets
Assembly:  System (in System.dll)

public abstract class WebSocket : IDisposable

The WebSocket type exposes the following members.

  NameDescription
Protected methodWebSocketCreates an instance of the WebSocket class.
Top

  NameDescription
Public propertyCloseStatusIndicates the reason why the remote endpoint initiated the close handshake.
Public propertyCloseStatusDescriptionAllows the remote endpoint to describe the reason why the connection was closed.
Public propertyStatic memberDefaultKeepAliveIntervalGets the default WebSocket protocol keep-alive interval in milliseconds.
Public propertyStateReturns the current state of the WebSocket connection.
Public propertySubProtocolThe subprotocol that was negotiated during the opening handshake.
Top

  NameDescription
Public methodAbortAborts the WebSocket connection and cancels any pending IO operations.
Public methodCloseAsyncCloses the WebSocket connection as an asynchronous operation using the close handshake defined in the WebSocket protocol specification section 7.
Public methodCloseOutputAsyncInitiates or completes the close handshake defined in the WebSocket protocol specification section 7.
Public methodStatic memberCreateClientBufferCreate client buffers to use with this WebSocket instance.
Public methodStatic memberCreateClientWebSocketThis 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.
Public methodStatic memberCreateServerBufferCreates a WebSocket server buffer.
Public methodDisposeUsed to clean up unmanaged resources for ASP.NET and self-hosted implementations.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberIsApplicationTargeting45 Obsolete. Returns a value that indicates if the WebSocket instance is targeting .NET Framework 4.5.
Protected methodStatic memberIsStateTerminalReturns a value that indicates if the state of the WebSocket instance is closed or aborted.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReceiveAsyncReceives data from the WebSocket connection asynchronously.
Public methodStatic memberRegisterPrefixesThis 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).
Public methodSendAsyncSends data over the WebSocket connection asynchronously.
Protected methodStatic memberThrowOnInvalidStateVerifies that the connection is in an expected state.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

.NET Framework

Supported in: 4.6, 4.5

Windows 8.1, Windows Server 2012 R2, 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft