Boost logo

Boost :

Subject: Re: [boost] [asio] resolve hostname from numeric IP address?
From: Brian and Victoria (bnv_at_[hidden])
Date: 2009-03-14 15:20:24


This took several hours of web searching and trying to make sense of the
asio documentation, but...

<snip>
boost::asio::ip::tcp::endpoint
ep(boost::asio::ip::address_v4(0xD155AB64), 80); // 209.85.171.100:80
boost::asio::ip::tcp::resolver resolver(ios);
boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(ep);
boost::asio::ip::tcp::resolver::iterator end;
while (iter != end)
{
  std::cerr << (*iter).host_name() << std::endl; // cg-in-f100.google.com
  ++iter;
}
<snip>

...produces the desired results.

I'm posting this because I found other posts like mine that had not been
responded to.

-Brian

Brian and Victoria wrote:
> I'm having trouble parsing the documentation, and am trying to
> determine if asio supports gethostbyaddr() functionality.
>
> The resolver appears to support hostname to addr queries, but I'm
> looking for addr to hostname (e.g., 127.0.0.1 maps to localhost).
>
> If so, a pointer to an example would be greatly appreciated.
>
> Thanks,
> Brian
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk