PyDocs

Nav

Networking and Interprocess Communication

create_connection

socket

function (source) not WASI
  • create_connection(address, timeout=GLOBAL_DEFAULT, source_address=None, *, all_errors=False)
Connect to *address* and return the socket object.

Convenience function.  Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object.  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.  If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
A host of '' or port 0 tells the OS to use the default. When a connection
cannot be created, raises the last error if *all_errors* is False,
and an ExceptionGroup of all errors if *all_errors* is True.
Changed in 3.2, 3.11
  • 3.2: source_address was added.
  • 3.11: all_errors was added.
0 Examples
No examples for socket/create_connection.
See Also
No see-alsos for socket/create_connection
0 Notes
No notes for create_connection