WebSocket.CreateClientWebSocket Method

Definition

Allows callers to create a client side WebSocket class which will use the WSPC for framing purposes.

This API supports the product infrastructure and is not intended to be used directly from your code.

C#
public static System.Net.WebSockets.WebSocket CreateClientWebSocket(System.IO.Stream innerStream, string? subProtocol, int receiveBufferSize, int sendBufferSize, TimeSpan keepAliveInterval, bool useZeroMaskingKey, ArraySegment<byte> internalBuffer);
C#
public static System.Net.WebSockets.WebSocket CreateClientWebSocket(System.IO.Stream innerStream, string subProtocol, int receiveBufferSize, int sendBufferSize, TimeSpan keepAliveInterval, bool useZeroMaskingKey, ArraySegment<byte> internalBuffer);

Parameters

innerStream
Stream

The connection to be used for IO operations.

subProtocol
String

The subprotocol accepted by the client.

receiveBufferSize
Int32

The size in bytes of the client WebSocket receive buffer.

sendBufferSize
Int32

The size in bytes of the client WebSocket send buffer.

keepAliveInterval
TimeSpan

Determines how regularly a frame is sent over the connection as a keep-alive. Applies only when the connection is idle.

useZeroMaskingKey
Boolean

Indicates whether a random key or a static key (just zeros) should be used for the WebSocket masking.

internalBuffer
ArraySegment<Byte>

Will be used as the internal buffer in the WPC. The size has to be at least 2 * ReceiveBufferSize + SendBufferSize + 256 + 20 (16 on 32-bit).

Returns

Returns WebSocket.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1