|
Boost Users : |
Subject: [Boost-users] [asio] How to get the name of the endpoint from the ip address of the endpoint.
From: Andrew Maclean (andrew.amaclean_at_[hidden])
Date: 2009-02-02 19:44:59
If I have an endpoint as an ip address (IP V4 or IPv6), how can I do a
DNS lookup to get the name of the endpoint?
In the example below, I understand that the host_name is coming from
the query. But how do I do a lookup to get the host name from the IP?
This may help.
If I do something like this:
ip::tcp::resolver_iterator res =
ip::tcp::resolver(ios).resolve(ip::tcp::resolver_query("google.com",
"80"));
for(;res != ip::tcp::resolver_iterator(); ++res)
{
std::cout << res->host_name() << ":" << res->service_name() << " ";
std::cout << res->endpoint().address().to_string() << std::endl;
}
The the output is:
google.com:80 209.85.171.100
google.com:80 74.125.67.100
google.com:80 74.125.45.100
However if I do:
ip::tcp::resolver_iterator res =
ip::tcp::resolver(ios).resolve(ip::tcp::resolver_query("209.85.171.100",
"80"));
I get:
209.85.171.100:80 209.85.171.100
so th ehosr name comes from the query.
I really want:
google.com:80 209.85.171.100
Thanks in advance for any help.
Andrew
-- ___________________________________________ Andrew J. P. Maclean Centre for Autonomous Systems The Rose Street Building J04 The University of Sydney 2006 NSW AUSTRALIA Ph: +61 2 9351 3283 Fax: +61 2 9351 7474 URL: http://www.acfr.usyd.edu.au/ ___________________________________________
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