diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2012-02-09 09:54:17 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2012-02-09 09:54:17 (GMT) |
commit | 6e13f130a9bde00db9fc17934987ed36da251aa7 (patch) | |
tree | 2b1be197ce7c94598ad2c9f52286a293b7219bcd /Doc/library/socket.rst | |
parent | b2c9e9ad91542e28a77efabe6b16a7021ccc34d3 (diff) | |
download | cpython-6e13f130a9bde00db9fc17934987ed36da251aa7.zip cpython-6e13f130a9bde00db9fc17934987ed36da251aa7.tar.gz cpython-6e13f130a9bde00db9fc17934987ed36da251aa7.tar.bz2 |
Fix Issue #6005: Examples in the socket library documentation use sendall,
where relevant, instead send method.
Diffstat (limited to 'Doc/library/socket.rst')
-rw-r--r-- | Doc/library/socket.rst | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index b31eb92..f236d30 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -731,7 +731,8 @@ correspond to Unix system calls applicable to sockets. optional *flags* argument has the same meaning as for :meth:`recv` above. Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the - application needs to attempt delivery of the remaining data. + application needs to attempt delivery of the remaining data. For further + information on this topic, consult the :ref:`socket-howto`. .. method:: socket.sendall(bytes[, flags]) @@ -886,8 +887,8 @@ using it. Note that a server must perform the sequence :func:`socket`, :meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly repeating the :meth:`~socket.accept` to service more than one client), while a client only needs the sequence :func:`socket`, :meth:`~socket.connect`. Also -note that the server does not :meth:`~socket.send`/:meth:`~socket.recv` on the -socket it is listening on but on the new socket returned by +note that the server does not :meth:`~socket.sendall`/:meth:`~socket.recv` on +the socket it is listening on but on the new socket returned by :meth:`~socket.accept`. The first two examples support IPv4 only. :: @@ -905,7 +906,7 @@ The first two examples support IPv4 only. :: while True: data = conn.recv(1024) if not data: break - conn.send(data) + conn.sendall(data) conn.close() :: @@ -917,7 +918,7 @@ The first two examples support IPv4 only. :: PORT = 50007 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) - s.send(b'Hello, world') + s.sendall(b'Hello, world') data = s.recv(1024) s.close() print('Received', repr(data)) @@ -989,7 +990,7 @@ sends traffic to the first one connected successfully. :: if s is None: print('could not open socket') sys.exit(1) - s.send(b'Hello, world') + s.sendall(b'Hello, world') data = s.recv(1024) s.close() print('Received', repr(data)) |