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

◆ enable_broadcast() [2/2]

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

Sets a boolean value that specifies whether the xtd::net::sockets::udp_client may send or receive broadcast packets.

Parameters
valuetrue if the xtd::net::sockets::udp_client allows broadcast packets; otherwise, false. The default is false.
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
Broadcasting is limited to a specific subnet. You can broadcast to your local subnet by sending a packet to 255.255.255.255; or, you can use the directed broadcast address, which is the network portion of an Internet Protocol (IP) address with all bits set in the host portion. For example, if your IP address is 192.168.1.40 (a Class C address, with the network portion as the first three octets, and the host portion is the last octet), your directed broadcast address is 192.168.1.255.
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.