mirror of https://github.com/python/cpython
Issue #13724: improve documentation for socket.create_connection.
This commit is contained in:
parent
9e0839006e
commit
d716c73d03
|
@ -207,10 +207,17 @@ The module :mod:`socket` exports the following constants and functions:
|
||||||
|
|
||||||
.. function:: create_connection(address[, timeout[, source_address]])
|
.. function:: create_connection(address[, timeout[, source_address]])
|
||||||
|
|
||||||
Convenience function. Connect to *address* (a 2-tuple ``(host, port)``),
|
Connect to a TCP service listening on the Internet *address* (a 2-tuple
|
||||||
and return the socket object. Passing the optional *timeout* parameter will
|
``(host, port)``), and return the socket object. This is a higher-level
|
||||||
set the timeout on the socket instance before attempting to connect. If no
|
function than :meth:`socket.connect`: if *host* is a non-numeric hostname,
|
||||||
*timeout* is supplied, the global default timeout setting returned by
|
it will try to resolve it for both :data:`AF_INET` and :data:`AF_INET6`,
|
||||||
|
and then try to connect to all possible addresses in turn until a
|
||||||
|
connection succeeds. This makes it easy to write clients that are
|
||||||
|
compatible to both IPv4 and IPv6.
|
||||||
|
|
||||||
|
Passing the optional *timeout* parameter will set the timeout on the
|
||||||
|
socket instance before attempting to connect. If no *timeout* is
|
||||||
|
supplied, the global default timeout setting returned by
|
||||||
:func:`getdefaulttimeout` is used.
|
:func:`getdefaulttimeout` is used.
|
||||||
|
|
||||||
If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the
|
If supplied, *source_address* must be a 2-tuple ``(host, port)`` for the
|
||||||
|
|
Loading…
Reference in New Issue