[Python-Dev] The socket HOWTO

Antoine Pitrou solipsis at pitrou.net
Mon Jun 6 09:17:20 CEST 2011


On Mon, 06 Jun 2011 00:22:11 +0200
"Martin v. Löwis" <martin at v.loewis.de> wrote:
> >>> I'm not sure why the examples are good (for example, modern client
> >>> code should probably use create_connection() with a host name, not
> >>> connect()).
> >>
> >> I disagree. create_connection is an advanced function - you shouldn't
> >> be using it unless you know what it is doing.
> > 
> > Can you explain? I would certainly use it myself, and I don't
> > understand how it's "advanced". It's simply higher-level.
> 
> It uses getaddrinfo, which might return multiple addresses, which
> are then tried in sequence. So even though it's called
> "create_connection", it may actually attempt to create multiple
> connections. As a consequence, it may wait some time for one connection
> to complete, and then succeed on a different address.
> 
> These phenomena can only be understood when you know what it is
> actually doing.

So what? You can say the exact same thing about every API under the sun.
Yet the sockets HOWTO *doesn't* explain what the socket APIs are
actually doing.



More information about the Python-Dev mailing list