Fix Issue #6005: Examples in the socket library documentation use sendall,
where relevant, instead send method. Patch contributed by Brian Brazil.
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index bcb317b..8ac47fb 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -725,7 +725,8 @@
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 concept, consult the :ref:`socket-howto`.
.. method:: socket.sendall(string[, flags])
@@ -863,8 +864,8 @@
: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. ::
@@ -882,7 +883,7 @@
while 1:
data = conn.recv(1024)
if not data: break
- conn.send(data)
+ conn.sendall(data)
conn.close()
::
@@ -894,7 +895,7 @@
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('Hello, world')
+ s.sendall('Hello, world')
data = s.recv(1024)
s.close()
print 'Received', repr(data)
@@ -966,7 +967,7 @@
if s is None:
print 'could not open socket'
sys.exit(1)
- s.send('Hello, world')
+ s.sendall('Hello, world')
data = s.recv(1024)
s.close()
print 'Received', repr(data)