संपादित करें

इसके माध्यम से साझा किया गया


SocketTaskExtensions.AcceptAsync Method

Definition

Overloads

AcceptAsync(Socket)

Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

AcceptAsync(Socket, Socket)

Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

AcceptAsync(Socket)

Source:
SocketTaskExtensions.cs
Source:
SocketTaskExtensions.cs
Source:
SocketTaskExtensions.cs

Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<System::Net::Sockets::Socket ^> ^ AcceptAsync(System::Net::Sockets::Socket ^ socket);
public static System.Threading.Tasks.Task<System.Net.Sockets.Socket> AcceptAsync (this System.Net.Sockets.Socket socket);
static member AcceptAsync : System.Net.Sockets.Socket -> System.Threading.Tasks.Task<System.Net.Sockets.Socket>
<Extension()>
Public Function AcceptAsync (socket As Socket) As Task(Of Socket)

Parameters

socket
Socket

The socket that is listening for connections.

Returns

An asynchronous task that completes with a Socket to handle communication with the remote host.

Exceptions

An invalid operation was requested. This exception occurs if the accepting Socket is not listening for connections or the accepted socket is bound.

You must call the Bind(EndPoint) and Listen(Int32) method before calling the AcceptAsync(Socket) method.

An error occurred when attempting to access the socket.

The Socket has been closed.

Applies to

AcceptAsync(Socket, Socket)

Source:
SocketTaskExtensions.cs
Source:
SocketTaskExtensions.cs
Source:
SocketTaskExtensions.cs

Performs an asynchronous operation on to accept an incoming connection attempt on the socket.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<System::Net::Sockets::Socket ^> ^ AcceptAsync(System::Net::Sockets::Socket ^ socket, System::Net::Sockets::Socket ^ acceptSocket);
public static System.Threading.Tasks.Task<System.Net.Sockets.Socket> AcceptAsync (this System.Net.Sockets.Socket socket, System.Net.Sockets.Socket? acceptSocket);
public static System.Threading.Tasks.Task<System.Net.Sockets.Socket> AcceptAsync (this System.Net.Sockets.Socket socket, System.Net.Sockets.Socket acceptSocket);
static member AcceptAsync : System.Net.Sockets.Socket * System.Net.Sockets.Socket -> System.Threading.Tasks.Task<System.Net.Sockets.Socket>
<Extension()>
Public Function AcceptAsync (socket As Socket, acceptSocket As Socket) As Task(Of Socket)

Parameters

socket
Socket

The socket that is listening for incoming connections.

acceptSocket
Socket

The accepted Socket object. This value may be null.

Returns

An asynchronous task that completes with a Socket to handle communication with the remote host.

Exceptions

An invalid operation was requested. This exception occurs if the accepting Socket is not listening for connections or the accepted socket is bound.

You must call the Bind(EndPoint) and Listen(Int32) method before calling the AcceptAsync(Socket, Socket) method.

An error occurred when attempting to access the socket.

The Socket has been closed.

Applies to