WebSocket.SendAsync Method (ArraySegment<Byte>, WebSocketMessageType, Boolean, CancellationToken)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Sends data over the WebSocket connection asynchronously.

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

public abstract Task SendAsync(
	ArraySegment<byte> buffer,
	WebSocketMessageType messageType,
	bool endOfMessage,
	CancellationToken cancellationToken


Type: System.ArraySegment<Byte>

The buffer to be sent over the connection.

Type: System.Net.WebSockets.WebSocketMessageType

Indicates whether the application is sending a binary or text message.

Type: System.Boolean

Indicates whether the data in “buffer” is the last part of a message.

Type: System.Threading.CancellationToken

The token that propagates the notification that operations should be canceled.

Return Value

Type: System.Threading.Tasks.Task

The task object representing the asynchronous operation.

This operation will not block. The returned Task object will complete after the data has been sent on the WebSocket.

Exactly one send and one receive is supported on each WebSocket object in parallel.

.NET Framework
Available since 4.5
Return to top