Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
basic_datagram_socket::local_endpoint (2 of 2 overloads)

Inherited from basic_socket.

Get the local endpoint of the socket.

endpoint_type local_endpoint(
    boost::system::error_code & ec) const;

This function is used to obtain the locally bound endpoint of the socket.



Set to indicate what error occurred, if any.

Return Value

An object that represents the local endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.

boost::asio::ip::tcp::socket socket(io_service);
boost::system::error_code ec;
boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec);
if (ec)
  // An error occurred.