WebSocket.CloseAsync Method

.NET Framework 4.5

Closes the WebSocket connection as an asynchronous operation using the close handshake defined in the WebSocket protocol specification section 7.

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

public abstract Task CloseAsync(
	WebSocketCloseStatus closeStatus,
	string statusDescription,
	CancellationToken cancellationToken
)

Parameters

closeStatus
Type: System.Net.WebSockets.WebSocketCloseStatus

Indicates the reason for closing the WebSocket connection.

statusDescription
Type: System.String

Specifies a human readable explanation as to why the connection is closed.

cancellationToken
Type: System.Threading.CancellationToken

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

Return Value

Type: System.Threading.Tasks.Task
Returns Task.
The task object representing the asynchronous operation.

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

This method closes the WebSocket connection using the close handshake defined in the WebSocket protocol specification section 7.

.NET Framework

Supported in: 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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft