classification
Title: socket.create_connection and multiple IP addresses
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, giampaolo.rodola, kiilerix, pitrou, python-dev
Priority: normal Keywords:

Created on 2012-01-06 22:13 by kiilerix, last changed 2012-01-12 07:12 by pitrou. This issue is now closed.

Messages (4)
msg150772 - (view) Author: Mads Kiilerich (kiilerix) * Date: 2012-01-06 22:13
Forked from issue13721 where I was too lazy to report it separately:

http://docs.python.org/release/2.7.2/library/socket#socket.create_connection doesn't describe how it loops over all IP addresses. That seems to be the functions main advantage (and a gotcha) compared to creating the socket and connecting directly.

I propose to warn that it might "hang" up to n*timeout before anything happens with something like this in documentation and docstring:

... and return the socket object.
If the host resolves to multiple IP addresses then they will all be tried in turn until one of them succeeds.
Passing the optional timeout parameter will set the timeout on the socket instance before each attempt to connect.
If no ...
msg150781 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-07 00:28
> http://docs.python.org/release/2.7.2/library/socket#socket.create_connection doesn't describe how it loops over all IP addresses. That seems to be the functions main advantage (and a gotcha) compared to creating the socket and connecting directly.

Well the main advantage is that it makes it much easier to write clients
supporting both IPv4 and IPv6.
msg151117 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-12 07:11
New changeset 5594cd88bfed by Antoine Pitrou in branch '3.2':
Issue #13724: improve documentation for socket.create_connection.
http://hg.python.org/cpython/rev/5594cd88bfed

New changeset 43d08528223c by Antoine Pitrou in branch 'default':
Issue #13724: improve documentation for socket.create_connection.
http://hg.python.org/cpython/rev/43d08528223c

New changeset 60e77810a47e by Antoine Pitrou in branch '2.7':
Issue #13724: improve documentation for socket.create_connection.
http://hg.python.org/cpython/rev/60e77810a47e
msg151118 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-12 07:11
Wording fixed, thank you.
History
Date User Action Args
2012-01-12 07:12:00pitrousetstatus: open -> closed
resolution: fixed
stage: resolved
2012-01-12 07:11:52pitrousetmessages: + msg151118
versions: + Python 3.2, Python 3.3
2012-01-12 07:11:23python-devsetnosy: + python-dev
messages: + msg151117
2012-01-07 11:31:19giampaolo.rodolasetnosy: + giampaolo.rodola
2012-01-07 00:28:31pitrousetmessages: + msg150781
2012-01-06 22:13:49kiilerixcreate