Boost logo

Boost Users :

Subject: Re: [Boost-users] [ASIO] Resolve hostname to IPv4 or IPv6
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2010-05-31 06:57:35


On Sat, 29 May 2010 19:39:50 +0100, Alexander Lamaison wrote:

> I'm trying to add IPv6 support to my program without breaking IPv4. What
> is the canonical way, if any, to do this win ASIO on Windows.
...

> I originally though that all_matching would mean this code would resolve an
> IPv6 address if necessary but it doesn't. So I made the following changes:
>
> tcp::resolver resolver(m_io);
> typedef tcp::resolver::query Lookup;
> Lookup query(
> tcp::v6(), host_name, lexical_cast<string>(port),
> Lookup::all_matching | Lookup::v4_mapped |
> Lookup::numeric_service);
>
> This works on my test IPv6 setup but is it good enough? There are all
> sorts of things I don't understand like mapping and tunnelling so I'm
> looking for a best practice for IP-agnostic name resolution.

Turns out, this does indeed break IPv4 when run from an OS such as Windows
2000 that doesn't have IPv6. How can I resolve a hostname in both
situations?

Many thanks.

Alex Lamaison

--
SFTP for Windows Explorer (http://www.swish-sftp.org)

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