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

◆ shutdown()

void xtd::net::sockets::socket::shutdown ( xtd::net::sockets::socket_shutdown  how)

Disables sends and receives on a xtd::net::sockets::socket.

Parameters
howOne of the xtd::net::sockets::socket_shutdown values that specifies the operation that will no longer be allowed.
Exceptions
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the socket.
xtd::object_closed_exceptionThe xtd::net::sockets::socket has been closed.
Remarks
When using a connection-oriented xtd::net::sockets::socket, always call the xtd::net::sockets::socket::shutdown method before closing the xtd::net::sockets::socket::socket. This ensures that all data is sent and received on the connected socket before it is closed.
Call the xtd::net::sockets::socket::close method to free all resources associated with the xtd::net::sockets::socket. Do not attempt to reuse the xtd::net::sockets::socket after closing.
The following table shows the xtd::net::sockets::socket_shutdown enumeration values that are valid for the how parameter.
Value Description
xtd::net::sockets::socket_shutdown::send Disable sending on this xtd::net::sockets::socket.
xtd::net::sockets::socket_shutdown::receive Disable receiving on this xtd::net::sockets::socket.
xtd::net::sockets::socket_shutdown::both Disable both sending and receiving on this xtd::net::sockets::socket.
Setting how to xtd::net::sockets::socket_shutdown::send specifies that subsequent calls to xtd::net::sockets::socket::send are not allowed. If you are using a connectionless xtd::net::sockets::socket, specifying xtd::net::sockets::socket_shutdown::send will have no effect.
Setting how to xtd::net::sockets::socket_shutdown::receive specifies that subsequent calls to xtd::net::sockets::socket::receive are not allowed. This has no effect on lower protocol layers. If you are using a connection-oriented protocol, the connection is terminated if either of the following conditions exist after a call to xtd::net::sockets::socket::shutdown :
  • Data is in the incoming network buffer waiting to be received.
  • More data has arrived.
If you are using a connectionless protocol, datagrams are accepted and queued. However, if no buffer space is available for additional incoming datagrams, they will be discarded and no error will be returned to the sender. Using xtd::net::sockets::socket::shutdown on a connectionless xtd::net::sockets::socket is not recommended.
Setting how to xtd::net::sockets::socket_shutdown::both disables both sends and receives as described above.
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.