WebSocket.CloseOutputAsync Method

Definition

Initiates or completes the close handshake defined in the WebSocket protocol specification section 7.

public abstract System.Threading.Tasks.Task CloseOutputAsync (System.Net.WebSockets.WebSocketCloseStatus closeStatus, string? statusDescription, System.Threading.CancellationToken cancellationToken);
public abstract System.Threading.Tasks.Task CloseOutputAsync (System.Net.WebSockets.WebSocketCloseStatus closeStatus, string statusDescription, System.Threading.CancellationToken cancellationToken);

Parameters

closeStatus
WebSocketCloseStatus

Indicates the reason for closing the WebSocket connection.

statusDescription
String

Allows applications to specify a human readable explanation as to why the connection is closed.

cancellationToken
CancellationToken

The token that can be used to propagate notification that operations should be canceled.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

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

Applies to

Product Versies
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.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