Socket.DisconnectAsync(SocketAsyncEventArgs) Socket.DisconnectAsync(SocketAsyncEventArgs) Socket.DisconnectAsync(SocketAsyncEventArgs) Socket.DisconnectAsync(SocketAsyncEventArgs) Method

定义

开始异步请求从远程终结点断开连接。Begins an asynchronous request to disconnect from a remote endpoint.

public:
 bool DisconnectAsync(System::Net::Sockets::SocketAsyncEventArgs ^ e);
public bool DisconnectAsync (System.Net.Sockets.SocketAsyncEventArgs e);
member this.DisconnectAsync : System.Net.Sockets.SocketAsyncEventArgs -> bool
Public Function DisconnectAsync (e As SocketAsyncEventArgs) As Boolean

参数

e
SocketAsyncEventArgs SocketAsyncEventArgs SocketAsyncEventArgs SocketAsyncEventArgs

要用于此异步套接字操作的 SocketAsyncEventArgs 对象。The SocketAsyncEventArgs object to use for this asynchronous socket operation.

返回

如果 I/O 操作挂起,则为 truetrue if the I/O operation is pending. 操作完成时,将引发 e 参数的 Completed 事件。The Completed event on the e parameter will be raised upon completion of the operation.

如果 I/O 操作同步完成,则为 falsefalse if the I/O operation completed synchronously. 在这种情况下,将不会引发 e 参数的 Completed 事件,并且可能在方法调用返回后立即检查作为参数传递的 e 对象以检索操作的结果。In this case, The 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.

异常

e 参数不能为 null。The e parameter cannot be null.

已经在使用 e 参数中指定的 SocketAsyncEventArgs 对象执行套接字操作。A socket operation was already in progress using the SocketAsyncEventArgs object specified in the e parameter.

此方法需要 Windows XP 或更高版本。Windows XP or later is required for this method.

尝试访问套接字时出错。An error occurred when attempting to access the socket.

注解

使用面向连接的协议时,调用DisconnectAsync方法请求从远程终结点断开连接。When using a connection-oriented protocol, calling the DisconnectAsync method requests a disconnect from a remote endpoint. 如果您设置SocketAsyncEventArgs.DisconnectReuseSockettruee参数,可以重复使用套接字。If you set SocketAsyncEventArgs.DisconnectReuseSocket to true in the e parameter, the socket can be reused.

适用于

另请参阅