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

◆ local_end_point()

xtd::sptr< xtd::net::end_point > xtd::net::sockets::socket::local_end_point ( ) const

Gets the local endpoint.

Returns
The xtd::net::end_point that the xtd::net::sockets::socket is using for communications.
Exceptions
xtd::object_closed_exceptionThe xtd::net::sockets::socket has been closed.
Remarks
The xtd::net::sockets::socket::local_end_point property gets an xtd::net::end_point that contains the local IP address and port number to which your xtd::net::sockets::socket is bound. You must cast this xtd::net::end_point to an xtd::net::ip_end_point before retrieving any information. You can then call the xtd::net::ip_end_point::address method to retrieve the local xtd::net::ip_address, and the xtd::net::ip_end_point::port method to retrieve the local port number.
The xtd::net::sockets::socket::local_end_point property is usually set after you make a call to the xtd::net::sockets::socket::bind method. If you allow the system to assign your socket's local IP address and port number, the xtd::net::sockets::socket::local_end_point property will be set after the first I/O operation. For connection-oriented protocols, the first I/O operation would be a call to the xtd::net::sockets::socket::connect or xtd::net::sockets::socket::accept method. For connectionless protocols, the first I/O operation would be any of the send or receive calls.