TcpListener.EndAcceptSocket Method

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

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

member EndAcceptSocket : 
        asyncResult:IAsyncResult -> Socket


Type: System.IAsyncResult

An IAsyncResult returned by a call to the BeginAcceptSocket method.

Return Value

Type: System.Net.Sockets.Socket
A Socket.
The Socket used to send and receive data.


The underlying Socket has been closed.


The asyncResult parameter is a null reference (Nothing in Visual Basic).


The asyncResult parameter was not created by a call to the BeginAcceptSocket method.


The EndAcceptSocket method was previously called.


An error occurred while attempting to access the Socket. See the Remarks section for more information.

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


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


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 in the MSDN library at for a detailed description of the error.


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

The following code example demonstrates the use of the BeginAcceptSocket method to create and connect a socket. The callback delegate calls the EndAcceptSocket method to end the asynchronous request.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft