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

◆ udp_client() [5/6]

xtd::net::sockets::udp_client::udp_client ( uint16  port,
xtd::net::sockets::address_family  addressFamily 
)

Initializes a new instance of the xtd::net::sockets::udp_client class and binds it to the local port number provided.

Parameters
portThe port on which to listen for incoming connection attempts.
address_familyOne of the xtd::net::sockets::address_family values that specifies the addressing scheme of the socket.
Exceptions
xtd::argument_exceptionfamily is not xtd::net::sockets::address_family::inter_network or xtd::net::sockets::address_family::inter_network_v6.
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the underlying socket.
Remarks
This constructor creates an underlying xtd::net::sockets::socket and binds it to the port number from which you intend to communicate.
The family parameter determines whether the listener uses an IP version 4 address (IPv4) or an IP version 6 (IPv6) address. To use an IPv4 address, pass the xtd::net::sockets::address_family::inter_network value. To use an IPv6 address, pass the xtd::net::sockets::address_family::inter_network_v6 value. Passing any other value will cause the method to throw an xtd::argument_exception.
If this constructor is used, the xtd::net::sockets::udp_client instance is set with the address family specified by the family parameter that cannot be changed or overwritten by a connect method call with a different address family.
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.