
Hello Paolo,
I'm using the boost library to create and manage a UDP socket. I was wondering if there is a way to know the public address of my machine using the boost classes.
Using a resolver to retrieve the address from the host name seems to do the trick: #include <iostream> #include <boost/asio.hpp> int main(int argc, char** argv) { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::query query(boost::asio::ip::host_name(), ""); boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(query); boost::asio::ip::tcp::endpoint endpoint = *it; std::cout << endpoint.address().to_string() << '\n'; return 0; } Cheers, Bjorn Karlsson www.skeletonsoftware.net