Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 889a510

Browse files
committed
Issue #13724: improve documentation for socket.create_connection.
1 parent 0010256 commit 889a510

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Doc/library/socket.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,17 @@ The module :mod:`socket` exports the following constants and functions:
236236

237237
.. function:: create_connection(address[, timeout[, source_address]])
238238

239-
Convenience function. Connect to *address* (a 2-tuple ``(host, port)``),
240-
and return the socket object. Passing the optional *timeout* parameter will
241-
set the timeout on the socket instance before attempting to connect. If no
242-
*timeout* is supplied, the global default timeout setting returned by
239+
Connect to a TCP service listening on the Internet *address* (a 2-tuple
240+
``(host, port)``), and return the socket object. This is a higher-level
241+
function than :meth:`socket.connect`: if *host* is a non-numeric hostname,
242+
it will try to resolve it for both :data:`AF_INET` and :data:`AF_INET6`,
243+
and then try to connect to all possible addresses in turn until a
244+
connection succeeds. This makes it easy to write clients that are
245+
compatible to both IPv4 and IPv6.
246+
247+
Passing the optional *timeout* parameter will set the timeout on the
248+
socket instance before attempting to connect. If no *timeout* is
249+
supplied, the global default timeout setting returned by
243250
:func:`getdefaulttimeout` is used.
244251

245252
If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the

0 commit comments

Comments
 (0)