Upraviť

Zdieľať cez


Socket.EndDisconnect(IAsyncResult) Method

Definition

Ends a pending asynchronous disconnect request.

public:
 void EndDisconnect(IAsyncResult ^ asyncResult);
public void EndDisconnect (IAsyncResult asyncResult);
member this.EndDisconnect : IAsyncResult -> unit
Public Sub EndDisconnect (asyncResult As IAsyncResult)

Parameters

asyncResult
IAsyncResult

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

Exceptions

.NET Framework, .NET Core, and .NET 5-6 only: The Socket has been closed.

asyncResult is null.

asyncResult was not returned by a call to the BeginDisconnect(Boolean, AsyncCallback, Object) method.

EndDisconnect(IAsyncResult) was previously called for the asynchronous connection.

An error occurred when attempting to access the socket.

-or-

.NET 7+ only: The Socket has been closed.

The disconnect request has timed out.

Remarks

Important

This is a compatibility API. We don't recommend using the APM (Begin* and End*) methods for new development. Instead, use the Task-based equivalents.

EndDisconnect completes the operation started by BeginDisconnect. You need to pass the IAsyncResult created by the matching BeginDisconnect call. EndDisconnect will block the calling thread until the operation is completed.

Note

If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code.

Note

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

Applies to