Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Asio] Is there a way to find out first address of first NIC in the local host using Asio?
From: Igor R (boost.lists_at_[hidden])
Date: 2009-10-21 05:39:28


I'm not sure it is the *first* address of the *first* nic (depends of where
you begin to count :) ), but one of your IPs can be found out, for
example, this way:

 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 iter = resolver.resolve(query);
 boost::asio::ip::address addr = iter->endpoint().address();
 std::cout << addr.to_string();



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net