[Python-Dev] socket.create_connection slow
Victor Stinner
victor.stinner at haypocalc.com
Wed Jan 14 13:46:18 CET 2009
Hi,
Le Wednesday 14 January 2009 12:23:46 Kristján Valur Jónsson, vous avez
écrit :
> socket.create_connection() trying to connect to ("localhost", port)
> (...)
> return an AF_INET6 entry before the AF_INET one and try connection
> to that. This connect() attemt fails after approximately one second,
> after which we proceed to do an immediately successful connect() call
> to the AF_INET address.
This is the normal behaviour of dual stack (IPv4+IPv6): IPv6 is tried before
IPv4. SocketServer uses AF_INET by default, so the "IPv6 port" is closed on
your host. Why does it take so long to try to connect to the IPv6 port? On
Linux, it's immediate:
----
$ time nc6 ::1 8080
nc6: unable to connect to address ::1, service 8080
real 0m0.023s
user 0m0.000s
sys 0m0.008s
----
On my host (Ubuntu Gutsy), "localhost" name has only an IPv4 address. The
address "::1" is "ip6-localhost" or "ip6-loopback".
You should check why the connect() to IPv6 is so long to raise an error. About
the test: since SocketServer address family is constant (IPv4), you can force
IPv4 for the client.
--
Victor Stinner aka haypo
http://www.haypocalc.com/blog/
More information about the Python-Dev
mailing list