[docs] doc bug report

שחר י shaharyi88 at gmail.com
Wed Feb 3 15:37:13 EST 2016


Hello,

In the client-side code here:
https://docs.python.org/2/library/socketserver.html#socketserver-tcpserver-example

the line:

received = sock.recv(1024)

is a bad programming example.
This is not the proper way to receive data using a socket.
You must receive in a loop until a whole message is received or the socket
is closed (getting empty data).

The least you can do is say that this is only for the demo to work in most
cases. I.e., when the machine network card is not too busy.

To clarify, say the network card was busy and only managed to read 5 bytes
in the single recv() call you have. The client-output in this case would be
"PYTHON" and not "PYTHON IS NICE".

Regards,
Shahar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20160203/59b6565f/attachment.html>


More information about the docs mailing list