Export (0) Print
Expand All

HttpListenerContext.AcceptWebSocketAsync Method (String, Int32, TimeSpan)

.NET Framework 4.5

Accept a WebSocket connection specifying the supported WebSocket sub-protocol, receive buffer size, and WebSocket keep-alive interval as an asynchronous operation.

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

Public Function AcceptWebSocketAsync ( _
	subProtocol As String, _
	receiveBufferSize As Integer, _
	keepAliveInterval As TimeSpan _
) As Task(Of HttpListenerWebSocketContext)


Type: System.String

The supported WebSocket sub-protocol.

Type: System.Int32

The receive buffer size in bytes.

Type: System.TimeSpan

The WebSocket protocol keep-alive interval in milliseconds.

Return Value

Type: System.Threading.Tasks.Task(Of HttpListenerWebSocketContext)
Returns Task(Of TResult).
The task object representing the asynchronous operation. The Result property on the task object returns an HttpListenerWebSocketContext object.


subProtocol is an empty string


subProtocol contains illegal characters.


keepAliveInterval is too small.


receiveBufferSize is less than 16 bytes


receiveBufferSize is greater than 64K bytes.


An error occurred when sending the response to complete the WebSocket handshake.

This operation will not block. The returned Task(Of TResult) > object will complete after the WebSocket connection has been accepted.

.NET Framework

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

© 2014 Microsoft