xtd::net::sockets::udp_client::sends a UDP datagram to a specified port on a specified remote host.
- Parameters
-
dgram | An array of type Byte that specifies the UDP datagram that you intend to send represented as an array of bytes. |
bytes | The number of bytes in the datagram. |
hostname | The name of the remote host to which you intend to send the datagram. |
port | The remote port number with which you intend to communicate. |
- Returns
- The number of bytes sent.
- Exceptions
-
- Note
- Do not provide a host name or port number to this method if you have already established a remote host with the xtd::net::sockets::udp_client::connect method. If you do, the xtd::net::sockets::udp_client::send method will throw a xtd::net::sockets::socket_exception. If you receive a xtd::net::sockets::socket_exception, use xtd::net::sockets::socket_exception.ErrorCode to obtain the specific error code. Once you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.
-
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.