Boost logo

Boost :

Subject: [boost] Unexpected behavior in reverse lookup (asio resolver)
From: LC (myLC_at_[hidden])
Date: 2018-09-18 13:36:17

When performing a reverse lookup of an address:

*r->async_resolve( boost::asio::ip::tcp::resolver::endpoint_type( adr, 80 )

the address itself is returned (as string), when the name of the host cannot
be found. I would expect an error/exception, telling me this instead.

Consider the following (custom class which does both):
*Resolver::resolve< ResolverClass >( &rc, "", 1 );
Resolver::resolve< ResolverClass >( &rc, "", 2 );
Resolver::resolve< ResolverClass >( &rc, "none.exist.end", 3 );
Resolver::resolve< ResolverClass >( &rc, "", 4 );
Resolver::resolve< ResolverClass >( &rc, "", 5 );
Resolver::resolve< ResolverClass >( &rc, "", 6 );*

And the result:
*1: hostname:, address:, error:
1: hostname:, address:, error:
2: hostname:, address:, error:
3: hostname: , address:, error: Host not found (authoritative)
4: hostname:, address:, error:
5: hostname:, address:, error:
6: hostname:, address:, error:*

2 is looking up of "", which of course can be found and returns the entry.
Likewise, 4 and 5 can be found and return the correct result.
*Nr. 6, however, is a non-existent ip-address. As you can see, instead of an
error, the address itself is returned when calling
This is unexpected and (I think) undocumented. It can be easily detected by
testing if host_name returns an address, but this would require another
(test) conversion; as a result you'd end up with forth&back conversions.

Wouldn't it be better, if the reverse lookup returned an error/exception, if
the name of the host cannot be found? This would be more consistent with the
"Host not found (authoritative)" error in example 3.

Sent from:

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