Socket.BeginDisconnect Method (Boolean, AsyncCallback, Object)
Begins an asynchronous request to disconnect from a remote endpoint.
Assembly: System (in System.dll)
[<HostProtectionAttribute(SecurityAction.LinkDemand, ExternalThreading = true)>] member BeginDisconnect : reuseSocket:bool * callback:AsyncCallback * state:Object -> IAsyncResult
true if this socket can be reused after the connection is closed; otherwise, false.
An object that contains state information for this request.
The operating system is Windows 2000 or earlier, and this method requires Windows XP.
The Socket object has been closed.
An error occurred when attempting to access the socket. See the Remarks section for more information.
If you are using a connection-oriented protocol, you can call themethod to request a disconnect from a remote endpoint. If reuseSocket is true, you can reuse the socket.
If you receive a SocketException exception, 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 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 is called to begin a disconnect request. When the request completes, the Connected property is queried to test whether the socket is disconnected.
Available since 2.0