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

◆ udp_client() [6/6]

xtd::net::sockets::udp_client::udp_client ( const xtd::string hostname,
uint16  port 
)

Initializes a new instance of the xtd::net::sockets::udp_client class and establishes a default remote host.

Parameters
hostnameThe name of the remote DNS host to which you intend to connect.
portThe remote port number to which you intend to connect.
Exceptions
xtd::net::sockets::socket_exceptionAn error occurred when attempting to access the underlying socket.
Remarks
This constructor initializes a new xtd::net::sockets::udp_client and establishes a remote host using the hostname and port parameters. Establishing a default remote host is optional. If you use this constructor, you do not have to specify a remote host in each call to the xtd::net::sockets::udp_client::send method. Specifying a default remote host limits you to that host only. You can change the default remote host at any time by calling the xtd::net::sockets::udp_client::connect method. If you want to specify a remote host in your call to the xtd::net::sockets::udp_client::send method, do not use this constructor.
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.