Problem with slow httplib connections on Windows (and maybe other platforms)

rdmurray at bitdance.com rdmurray at bitdance.com
Sun Feb 1 20:33:28 CET 2009


Quoth Christoph Zwerschke <cito at online.de>:
> What actually happens is the following:
> 
> * BaseHTTPServer binds only to the IPv4 address of localhost, because
>    it's based on TCPServer which has address_family=AF_INET by default.
> 
> * HTTPConnection.connect() however tries to connect to all IP addresses
>    of localhost, in the order determined socket.getaddrinfo('localhost').
> 
>    With Py 2.3 (without IPv6 support) this is only the IPv4 address,
>    but with Py 2.4-2.6 the order is (on my Win XP host) the IPv6 address
>    first, then the IPv4 address. Since the IPv6 address is checked first,
>    this gives a timeout and causes the slow connect() call. The order by
>    which getaddrinfo returns IPv4/v6 under Linux seems to vary depending
>    on the glibc version, so it may be a problem on other platforms, too.

Based on something I read in another thread, this appears to be a problem
only under Windows.  Everybody else implemented the TCP/IP stack according
to spec, and the IPV6 connect attempt times out immediately, producing
no slowdown.

Microsoft, however....

--RDM




More information about the Python-list mailing list