Bewerken

Delen via


HttpListenerContext.AcceptWebSocketAsync Method

Definition

Accept a WebSocket connection as an asynchronous operation.

Overloads

AcceptWebSocketAsync(String)

Accept a WebSocket connection as an asynchronous operation.

AcceptWebSocketAsync(String, TimeSpan)

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

AcceptWebSocketAsync(String, Int32, TimeSpan)

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

AcceptWebSocketAsync(String, Int32, TimeSpan, ArraySegment<Byte>)

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

AcceptWebSocketAsync(String)

Source:
HttpListenerContext.cs
Source:
HttpListenerContext.cs
Source:
HttpListenerContext.cs

Accept a WebSocket connection as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::WebSockets::HttpListenerWebSocketContext ^> ^ AcceptWebSocketAsync(System::String ^ subProtocol);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string? subProtocol);
member this.AcceptWebSocketAsync : string -> System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext>
Public Function AcceptWebSocketAsync (subProtocol As String) As Task(Of HttpListenerWebSocketContext)

Parameters

subProtocol
String

The supported WebSocket sub-protocol.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns an HttpListenerWebSocketContext object.

Exceptions

subProtocol is an empty string

-or-

subProtocol contains illegal characters.

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

Remarks

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

The size of the receive buffer is 16,385 bytes. The WebSocket keep-alive interval is set to the default value of 30,000 (30 seconds).

See also

Applies to

AcceptWebSocketAsync(String, TimeSpan)

Source:
HttpListenerContext.cs
Source:
HttpListenerContext.cs
Source:
HttpListenerContext.cs

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

public:
 System::Threading::Tasks::Task<System::Net::WebSockets::HttpListenerWebSocketContext ^> ^ AcceptWebSocketAsync(System::String ^ subProtocol, TimeSpan keepAliveInterval);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, TimeSpan keepAliveInterval);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string? subProtocol, TimeSpan keepAliveInterval);
member this.AcceptWebSocketAsync : string * TimeSpan -> System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext>
Public Function AcceptWebSocketAsync (subProtocol As String, keepAliveInterval As TimeSpan) As Task(Of HttpListenerWebSocketContext)

Parameters

subProtocol
String

The supported WebSocket sub-protocol.

keepAliveInterval
TimeSpan

The WebSocket protocol keep-alive interval in milliseconds.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns an HttpListenerWebSocketContext object.

Exceptions

subProtocol is an empty string

-or-

subProtocol contains illegal characters.

keepAliveInterval is too small.

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

Remarks

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

The size of the receive buffer is 16,385 bytes.

See also

Applies to

AcceptWebSocketAsync(String, Int32, TimeSpan)

Source:
HttpListenerContext.Managed.cs
Source:
HttpListenerContext.Managed.cs
Source:
HttpListenerContext.Managed.cs

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

public:
 System::Threading::Tasks::Task<System::Net::WebSockets::HttpListenerWebSocketContext ^> ^ AcceptWebSocketAsync(System::String ^ subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string? subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval);
member this.AcceptWebSocketAsync : string * int * TimeSpan -> System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext>
Public Function AcceptWebSocketAsync (subProtocol As String, receiveBufferSize As Integer, keepAliveInterval As TimeSpan) As Task(Of HttpListenerWebSocketContext)

Parameters

subProtocol
String

The supported WebSocket sub-protocol.

receiveBufferSize
Int32

The receive buffer size in bytes.

keepAliveInterval
TimeSpan

The WebSocket protocol keep-alive interval in milliseconds.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns an HttpListenerWebSocketContext object.

Exceptions

subProtocol is an empty string

-or-

subProtocol contains illegal characters.

keepAliveInterval is too small.

-or-

receiveBufferSize is less than 16 bytes

-or-

receiveBufferSize is greater than 64K bytes.

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

Remarks

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

See also

Applies to

AcceptWebSocketAsync(String, Int32, TimeSpan, ArraySegment<Byte>)

Source:
HttpListenerContext.Managed.cs
Source:
HttpListenerContext.Managed.cs
Source:
HttpListenerContext.Managed.cs

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

public:
 System::Threading::Tasks::Task<System::Net::WebSockets::HttpListenerWebSocketContext ^> ^ AcceptWebSocketAsync(System::String ^ subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment<System::Byte> internalBuffer);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment<byte> internalBuffer);
public System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext> AcceptWebSocketAsync (string? subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment<byte> internalBuffer);
member this.AcceptWebSocketAsync : string * int * TimeSpan * ArraySegment<byte> -> System.Threading.Tasks.Task<System.Net.WebSockets.HttpListenerWebSocketContext>
Public Function AcceptWebSocketAsync (subProtocol As String, receiveBufferSize As Integer, keepAliveInterval As TimeSpan, internalBuffer As ArraySegment(Of Byte)) As Task(Of HttpListenerWebSocketContext)

Parameters

subProtocol
String

The supported WebSocket sub-protocol.

receiveBufferSize
Int32

The receive buffer size in bytes.

keepAliveInterval
TimeSpan

The WebSocket protocol keep-alive interval in milliseconds.

internalBuffer
ArraySegment<Byte>

An internal buffer to use for this operation.

Returns

The task object representing the asynchronous operation. The Result property on the task object returns an HttpListenerWebSocketContext object.

Exceptions

subProtocol is an empty string

-or-

subProtocol contains illegal characters.

keepAliveInterval is too small.

-or-

receiveBufferSize is less than 16 bytes

-or-

receiveBufferSize is greater than 64K bytes.

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

Remarks

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

See also

Applies to