System.Net.WebSockets.WebSocket.ReceiveAsync Method

Receives data from the WebSocket connection asynchronously.

Syntax

public abstract System.Threading.Tasks.Task<WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, System.Threading.CancellationToken cancellationToken)

Parameters

buffer
References the application buffer that is the storage location for the received data.
cancellationToken
Propagate the notification that operations should be canceled.

Returns

Returns System.Threading.Tasks.Task`1.

The task object representing the asynchronous operation. The System.Threading.Tasks.Task`1.Result property on the task object returns a byte array containing the received data.

Remarks

This operation will not block. The returned System.Threading.Tasks.Task`1 object will complete after the data has been received on the WebSocket.

Requirements

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