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

◆ udp_client() [2/6]

xtd::net::sockets::udp_client::udp_client ( uint16  port)
explicit

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

Parameters
portThe local port number from which you intend to communicate.
Exceptions
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. Use this constructor if you are only interested in setting the local port number. The underlying service provider will assign the local IP address. If you pass 0 to the constructor, the underlying service provider will assign a port number. If this constructor is used, the xtd::net::sockets::udp_client instance is set with an address family of IPv4 that cannot be changed or overwritten by a connect method call with an IPv6 target.
This constructor works only with IPv4 address types.
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.