Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Socket.DisconnectAsync Method

Begins an asynchronous request to disconnect from a remote endpoint.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)
public bool DisconnectAsync(
	SocketAsyncEventArgs e
)

Parameters

e
Type: System.Net.Sockets.SocketAsyncEventArgs
The System.Net.Sockets.SocketAsyncEventArgs object to use for this asynchronous socket operation.

Return Value

Type: System.Boolean
Returns true if the I/O operation is pending. The SocketAsyncEventArgs.Completed event on the e parameter will be raised upon completion of the operation.
Returns false if the I/O operation completed synchronously. In this case, The SocketAsyncEventArgs.Completed event on the e parameter will not be raised and the e object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
ExceptionCondition
ArgumentNullException

The e parameter cannot be null.

InvalidOperationException

A socket operation was already in progress using the System.Net.Sockets.SocketAsyncEventArgs object specified in the e parameter.

NotSupportedException

Windows XP or later is required for this method.

ObjectDisposedException

The Socket has been closed.

SocketException

An error occurred when attempting to access the socket.

When using a connection-oriented protocol, calling the DisconnectAsync method requests a disconnect from a remote endpoint. If you set SocketAsyncEventArgs.DisconnectReuseSocket to true in the e parameter, the socket can be reused.

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.