[Boost-bugs] [Boost C++ Libraries] #8503: Cannot connect to localhost without global connectivity

Subject: [Boost-bugs] [Boost C++ Libraries] #8503: Cannot connect to localhost without global connectivity
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-04-26 19:26:44


#8503: Cannot connect to localhost without global connectivity
-------------------------------------+--------------------------------------
 Reporter: Edward@… | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: localhost AI_ADDRCONFIG |
-------------------------------------+--------------------------------------
 On Windows, if there are no network cards installed or they are all
 disabled, attempts to resolve localhost fail. The problem is that by
 default, the default value for the basic_resolver_query constructor's
 resolve_flags parameter is address_configured, which is AI_ADDRCONFIG on
 Windows. However, as implemented AI_ADDRCONFIG is actually detrimental,
 particularly for resolution of loopback and link-local addresses.

 The rationale from the Google Chrome source code explains this. Here is
 the relevant snippet from !SystemHostResolverCall in
 [http://src.chromium.org/viewvc/chrome/trunk/src/net/dns/host_resolver_proc.cc
 host_resolver_proc.cc]:

 {{{
 #if defined(OS_WIN)
   // DO NOT USE AI_ADDRCONFIG ON WINDOWS.
   //
   // The following comment in <winsock2.h> is the best documentation I
 found
   // on AI_ADDRCONFIG for Windows:
   // Flags used in "hints" argument to getaddrinfo()
   // - AI_ADDRCONFIG is supported starting with Vista
   // - default is AI_ADDRCONFIG ON whether the flag is set or not
   // because the performance penalty in not having ADDRCONFIG in
   // the multi-protocol stack environment is severe;
   // this defaulting may be disabled by specifying the AI_ALL
 flag,
   // in that case AI_ADDRCONFIG must be EXPLICITLY specified to
   // enable ADDRCONFIG behavior
   //
   // Not only is AI_ADDRCONFIG unnecessary, but it can be harmful. If the
   // computer is not connected to a network, AI_ADDRCONFIG causes
 getaddrinfo
   // to fail with WSANO_DATA (11004) for "localhost", probably because of
 the
   // following note on AI_ADDRCONFIG in the MSDN getaddrinfo page:
   // The IPv4 or IPv6 loopback address is not considered a valid global
   // address.
   // See http://crbug.com/5234.
   //
   // OpenBSD does not support it, either.
   hints.ai_flags = 0;
 #else
   hints.ai_flags = AI_ADDRCONFIG;
 #endif
 }}}

 The developers of [http://xcb.freedesktop.org/ XCB] arrived at a similar
 conclusion. See their discussion on
 [http://thread.gmane.org/gmane.comp.freedesktop.xcb/6973 Bug: Can’t
 connect to localhost without global connectivity].

 Code using ASIO can work around this problem, but doing so would require
 platform-specific code and intricate knowledge of poorly documented
 platform-specific behavior.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8503>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC