Boost logo

Boost :

From: Giovanni P. Deretta (gpderetta_at_[hidden])
Date: 2006-06-23 11:36:19

Pedro Lamarão wrote:
> Peter Petrov escreveu:
>> Wow, a lot of changes.
>> There is one thing that caught my eye. In the changelog you have the
>> following comment:
>>> * Resolver replaces ipv4::host_resolver.
>>> ...
>>> ip::tcp::resolver resolver(io_service);
>> Why is "resolver" in the "ip::tcp" namespace? A DNS resolver certainly
>> has nothing to do with the TCP protocol. It should be in the "ip"
>> namespace instead.
> It shouldn't be in the "ip" namespace either.
> The name translation service in any modern operating system can return
> address objects for any network families it supports.
> In practice, getaddrinfo can return addresses for IPv4 and IPv6. There
> is no reason why it can't return addresses for any other kind of network
> (unless naming objects in that network is radically different from
> "host"/"service").

Just because the system resolver (getaddrinfo) could in principle
resolve all kind of addresses, it doesn't mean that the asio resolver

The asio resolver returns a protocol specific address (actually an
iterator to a list of protocol specific addresses) and thus is strongly
typed. If the resolver where to be generic, it would return an iterator
to an heterogeneous list of addresses: the address (and socket types
initialized from the address) would need to be dynamically typed. The
asio interface is designed with static (not dynamic) polymorphisms in
mind, so the resolver should be protocol specific.

Note that a tcp address is also an tcp6, ip and ip6 address (v4 and v6
polymorphism is built in the protocol), so it should rightly belong in
the 'ip' namespace.


Giovanni P. Deretta

Boost list run by bdawes at, gregod at, cpdaniel at, john at