Socket.EndDisconnect Method (IAsyncResult)

 

Ends a pending asynchronous disconnect request.

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

member EndDisconnect : 
        asyncResult:IAsyncResult -> unit

Parameters

asyncResult
Type: System.IAsyncResult

An IAsyncResult object that stores state information and any user-defined data for this asynchronous operation.

Exception Condition
NotSupportedException

The operating system is Windows 2000 or earlier, and this method requires Windows XP.

ObjectDisposedException

The Socket object has been closed.

ArgumentNullException

asyncResult is null.

ArgumentException

asyncResult was not returned by a call to the BeginDisconnect method.

InvalidOperationException

EndDisconnect was previously called for the asynchronous connection.

SocketException

An error occurred when attempting to access the socket. See the Remarks section for more information.

WebException

The disconnect request has timed out.

EndDisconnect completes a call to BeginDisconnect. The EndDisconnect method blocks until the disconnect completes. For information about asynchronous operations, see the Asynchronous Programming Overview topic in the MSDN library.

System_CAPS_noteNote

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.

System_CAPS_noteNote

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 creates a socket for asynchronous communication and sends some data to a remote host. When the data has been sent, Shutdown is called to stop the send and receive activity. Then BeginDisconnect is called to begin a disconnect request. The callback delegate calls EndDisconnect to end the asynchronous request. When the request completes, the Connected property is queried to test whether the socket is disconnected.

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

.NET Framework
Available since 2.0
Return to top
Show: