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

后端 未结 2 787
盖世英雄少女心
盖世英雄少女心 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:28

    The constructor for query defaults to having the flag "address_configured".

    ip::basic_resolver_query::address_configured

    Only return IPv4 addresses if a non-loopback IPv4 address is configured for the system. Only return IPv6 addresses if a non-loopback IPv6 address is configured for the system.

    While setting the flag to something else will work, it will also have the side effects of said flag. To avoid this use the "default" of the enum.

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

    It used to be possible to just use 0, but the library has become more strict to prevent accidental use of an int as the service name.

提交回复
热议问题