xtd 0.2.0
Loading...
Searching...
No Matches

◆ begin_disconnect()

xtd::sptr< xtd::iasync_result > xtd::net::sockets::socket::begin_disconnect ( bool  reuse_socket,
xtd::async_callback  callback,
const std::any &  state 
)

Begins an asynchronous request to disconnect from a remote endpoint.

Parameters
reuse_sockettrue if this socket can be reused after the connection is closed; otherwise, false.
callbackThe xtd::async_callback delegate.
stateAn object that contains state information for this request.
Returns
An xtd::iasync_result that references the asynchronous connection.
Exceptions
xtd::object_closed_exceptionThe xtd::net::sockets::socket has been closed.
xtd::invalid_operation_exceptionThe accepting socket is not listening for connections. You must call xtd::net::sockets::socket::bind and xtd::net::sockets::socket::listen before calling xtd::net::sockets::socket::accept().
Remarks
If you are using a connection-oriented protocol, you can call the xtd::net::sockets::socket::begin_disconnect method to request a disconnect from a remote endpoint. If reuse_socket is true, you can reuse the socket.
The xtd::net::sockets::socket::begin_disconnect method uses a separate thread to invoke the specified callback method. The xtd::net::sockets::socket::end_disconnect method blocks until the pending disconnect is complete.
Note
If you receive a xtd::net::sockets::socket_exception exception, use the xtd::net::sockets::socket_exception::error_code 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.