Edit

Share via


TcpListener.EndAcceptSocket(IAsyncResult) Method

Definition

Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication.

public:
 System::Net::Sockets::Socket ^ EndAcceptSocket(IAsyncResult ^ asyncResult);
public System.Net.Sockets.Socket EndAcceptSocket (IAsyncResult asyncResult);
member this.EndAcceptSocket : IAsyncResult -> System.Net.Sockets.Socket
Public Function EndAcceptSocket (asyncResult As IAsyncResult) As Socket

Parameters

asyncResult
IAsyncResult

An IAsyncResult returned by a call to the BeginAcceptSocket(AsyncCallback, Object) method.

Returns

A Socket.

The Socket used to send and receive data.

Exceptions

The underlying Socket has been closed.

The asyncResult parameter is null.

The asyncResult parameter was not created by a call to the BeginAcceptSocket(AsyncCallback, Object) method.

The EndAcceptSocket(IAsyncResult) method was previously called.

An error occurred while attempting to access the Socket.

Remarks

This method blocks until the operation is complete. To perform this operation synchronously, use the AcceptSocket method.

Note

You can call the RemoteEndPoint property of the returned Socket to identify the remote host's network address and port number.

Note

If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code and refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.

Note

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.

Applies to