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

◆ exclusive_address_use() [2/2]

udp_client & xtd::net::sockets::udp_client::exclusive_address_use ( bool  value)

Sets a boolean value that specifies whether the xtd::net::sockets::udp_client allows only one client to use a port.

Parameters
valuetrue if the xtd::net::sockets::udp_client allows only one client to use a specific port; otherwise, false. The default is true for Windows Server 2003 and Windows XP Service Pack 2 and later, and false for all other versions.
Returns
This current instance.
Exceptions
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the underlying socket.
xtd::object_closed_exceptionThe underlying xtd::net::sockets::socket has been closed.
Remarks
By default, multiple clients can use a specific port; however, only one of the clients can perform operations on the network traffic sent to the port. You can use the xtd::net::sockets::udp_client::exclusive_address_use property to prevent multiple clients from using a specific port.
This property must be set before the underlying socket is bound to a client port. If you call xtd::net::sockets::udp_client.xtd::net::sockets::udp_client(Int32), xtd::net::sockets::udp_client.xtd::net::sockets::udp_client(Int32, xtd::net::sockets::address_family), xtd::net::sockets::udp_client.xtd::net::sockets::udp_client(xtd::net::ip_end_point), or xtd::net::sockets::udp_client.xtd::net::sockets::udp_client(String, Int32), the client port is bound as a side effect of the constructor, and you cannot subsequently set the xtd::net::sockets::udp_client::exclusive_address_use property
Note
If you receive a xtd::net::sockets::socket_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.