开发者

Boost asio: Using IPv6 addresses in resolver::query works on Win32, but not on Linux

I am currently developing a simple server application which should be also IPv6 capable. 开发者_StackOverflow社区IPv6 works fine on Windows (using MSVC2010), but it does not on Linux.

Imagine following code:

boost::system::error_code ec;
std::string address="::1", service="http";
tcp::resolver resolver(io_service);
tcp::resolver::query query(address, service);
tcp::resolver::iterator resiter = resolver.resolve(query, ec);

if (ec)
    std::cout << "Cannot resolve address: " << address << "(" << ec.message() << ")" << std::endl;

The error message printed on Linux is "Host not found (authoritative)", while it works on Windows.

Any hints are welcome.


Linux and Windows have different behavior with respect to the search order of address returned by the name services. Try using different flags to gain more fine-grained control over the type of address you are querying for. For example, for this query you could use the numeric_host flag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜