Skip to content

Commit

Permalink
pythonGH-88968: Add notes about socket ownership transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Oct 5, 2022
1 parent 0e72606 commit ba9bf4b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ Opening network connections
*happy_eyeballs_delay*, *interleave*
and *local_addr* should be specified.

.. note::

The *sock* argument transfers ownership of the socket to the
transport created. To close the socket, call the transport's
:meth:`~asyncio.BaseTransport.close` method.

* *local_addr*, if given, is a ``(local_host, local_port)`` tuple used
to bind the socket locally. The *local_host* and *local_port*
are looked up using ``getaddrinfo()``, similarly to *host* and *port*.
Expand Down Expand Up @@ -577,6 +583,12 @@ Opening network connections
transport. If specified, *local_addr* and *remote_addr* should be omitted
(must be :const:`None`).

.. note::

The *sock* argument transfers ownership of the socket to the
transport created. To close the socket, call the transport's
:meth:`~asyncio.BaseTransport.close` method.

See :ref:`UDP echo client protocol <asyncio-udp-echo-client-protocol>` and
:ref:`UDP echo server protocol <asyncio-udp-echo-server-protocol>` examples.

Expand Down Expand Up @@ -688,6 +700,12 @@ Creating network servers
* *sock* can optionally be specified in order to use a preexisting
socket object. If specified, *host* and *port* must not be specified.

.. note::

The *sock* argument transfers ownership of the socket to the
server created. To close the socket, call the server's
:meth:`~asyncio.Server.close` method.

* *backlog* is the maximum number of queued connections passed to
:meth:`~socket.socket.listen` (defaults to 100).

Expand Down Expand Up @@ -789,6 +807,12 @@ Creating network servers
* *sock* is a preexisting socket object returned from
:meth:`socket.accept <socket.socket.accept>`.

.. note::

The *sock* argument transfers ownership of the socket to the
transport created. To close the socket, call the transport's
:meth:`~asyncio.BaseTransport.close` method.

* *ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over
the accepted connections.

Expand Down

0 comments on commit ba9bf4b

Please sign in to comment.