Socket.EndAccept Method (IAsyncResult)
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication.
Assembly: System (in System.dll)
asyncResult is null.
asyncResult was not created by a call to BeginAccept.
An error occurred when attempting to access the socket. See the Remarks section for more information.
The Socket has been closed.
method was previously called.
Windows NT is required for this method.
BeginAccept. Before calling BeginAccept, you need to create a callback method that implements the AsyncCallback delegate. This callback method executes in a separate thread, and is called by the system after the BeginAccept method returns. It must accept the asyncResult parameter returned from the BeginAccept method.completes a call to
Within the callback method, call the AsyncState method of the asyncResult parameter to obtain the Socket on which the connection attempt is being made. After obtaining the Socket, you can call the method to successfully complete the connection attempt.
The Socket that can be used to send data to and receive data from the remote host.method blocks until a connection is pending in the incoming connection queue. The method accepts the incoming connection and returns a new
If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library 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 ends an asynchronous request and creates a new Socket to accept an incoming connection request. For a complete example that demonstrates asynchronous communications with sockets, see Socket Code Examples.
Available since 1.1