How does Boost Asio's hostname resolution work on Linux? Is it possible to use NSS?

后端 未结 2 845
盖世英雄少女心
盖世英雄少女心 2021-02-15 17:46

I\'m attempting to make my networked application work locally (with both the server and client running on the same computer) when there is no network connection. This seems to

2条回答
  •  天命终不由人
    2021-02-15 18:14

    The problem was that the constructor for query has the address_configured flag set by default which won't return an address if the loopback device is the only device with an address. By just settings flags to 0 or anything other than address_configured the problem is fixed. Here is what I'm successfully using now:

    tcp::resolver::query query(host, PORT, boost::asio::ip::resolver_query_base::numeric_service);
    

    Hope this helps anyone with this problem in the future.

提交回复
热议问题