diff options
author | Yury Selivanov <yury@magic.io> | 2016-06-08 16:48:34 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-06-08 16:48:34 (GMT) |
commit | 81d167a4c55fa28b1b56b7b46a8ccafed71643db (patch) | |
tree | 059ffadb2075b32a8f093eba2fe7a807b89c5293 /Doc/library/asyncio-eventloop.rst | |
parent | 552bf94648f09f4df68be9fc34a22f3b8441a67a (diff) | |
parent | 55c5084223d0a91777f6ff48e1b5e1dd7e4ae09d (diff) | |
download | cpython-81d167a4c55fa28b1b56b7b46a8ccafed71643db.zip cpython-81d167a4c55fa28b1b56b7b46a8ccafed71643db.tar.gz cpython-81d167a4c55fa28b1b56b7b46a8ccafed71643db.tar.bz2 |
Merge 3.5 (asyncio, issue #27136)
Diffstat (limited to 'Doc/library/asyncio-eventloop.rst')
-rw-r--r-- | Doc/library/asyncio-eventloop.rst | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 2e529b1..809a3e7 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -492,7 +492,10 @@ Low-level socket operations .. coroutinemethod:: BaseEventLoop.sock_recv(sock, nbytes) - Receive data from the socket. The return value is a bytes object + Receive data from the socket. Modeled after blocking + :meth:`socket.socket.recv` method. + + The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by *nbytes*. @@ -501,13 +504,12 @@ Low-level socket operations This method is a :ref:`coroutine <coroutine>`. - .. seealso:: - - The :meth:`socket.socket.recv` method. - .. coroutinemethod:: BaseEventLoop.sock_sendall(sock, data) - Send data to the socket. The socket must be connected to a remote socket. + Send data to the socket. Modeled after blocking + :meth:`socket.socket.sendall` method. + + The socket must be connected to a remote socket. This method continues to send data from *data* until either all data has been sent or an error occurs. ``None`` is returned on success. On error, an exception is raised, and there is no way to determine how much data, if @@ -518,35 +520,35 @@ Low-level socket operations This method is a :ref:`coroutine <coroutine>`. - .. seealso:: - - The :meth:`socket.socket.sendall` method. - .. coroutinemethod:: BaseEventLoop.sock_connect(sock, address) - Connect to a remote socket at *address*. - - The *address* must be already resolved to avoid the trap of hanging the - entire event loop when the address requires doing a DNS lookup. For - example, it must be an IP address, not a hostname, for - :py:data:`~socket.AF_INET` and :py:data:`~socket.AF_INET6` address families. - Use :meth:`getaddrinfo` to resolve the hostname asynchronously. + Connect to a remote socket at *address*. Modeled after + blocking :meth:`socket.socket.connect` method. With :class:`SelectorEventLoop` event loop, the socket *sock* must be non-blocking. This method is a :ref:`coroutine <coroutine>`. + .. versionchanged:: 3.5.2 + ``address`` no longer needs to be resolved. ``sock_connect`` + will try to check if the *address* is already resolved by calling + :func:`socket.inet_pton`. If not, + :meth:`BaseEventLoop.getaddrinfo` will be used to resolve the + *address*. + .. seealso:: - The :meth:`BaseEventLoop.create_connection` method, the - :func:`open_connection` function and the :meth:`socket.socket.connect` - method. + :meth:`BaseEventLoop.create_connection` + and :func:`asyncio.open_connection() <open_connection>`. .. coroutinemethod:: BaseEventLoop.sock_accept(sock) - Accept a connection. The socket must be bound to an address and listening + Accept a connection. Modeled after blocking + :meth:`socket.socket.accept`. + + The socket must be bound to an address and listening for connections. The return value is a pair ``(conn, address)`` where *conn* is a *new* socket object usable to send and receive data on the connection, and *address* is the address bound to the socket on the other end of the @@ -558,8 +560,7 @@ Low-level socket operations .. seealso:: - The :meth:`BaseEventLoop.create_server` method, the :func:`start_server` - function and the :meth:`socket.socket.accept` method. + :meth:`BaseEventLoop.create_server` and :func:`start_server`. Resolve host name |