[Python-Dev] noreply@sourceforge.net: [Python-bugs-list] [Bug #111620] lots of use of send() without verifyi ng amount of d
Gordon McMillan
gmcm@hypernet.com
Fri, 11 Aug 2000 12:25:18 -0400
[Guido]
> I just read the man page for send() (Red Hat linux 6.1) and it
> doesn't mention sending fewer than all bytes at all. In fact,
> while it says that the return value is the number of bytes sent,
> it at least *suggests* that it will return an error whenever not
> everything can be sent -- even in non-blocking mode.
It says (at least on RH 5.2): "If the message is too long to
pass atomically through the underlying protocol...". Hey guys,
TCP/IP is a stream protocol! For TCP/IP this is all completely
misleading.
Yes, it returns the number of bytes sent. For TCP/IP it is *not*
an error to send less than the argument. It's only an error if the
other end dies at the time of actual send.
Python has been behaving properly all along. The bug report is
correct. It's the usage of send in the std lib that is improper
(though with a nearly infinitessimal chance of breaking, since
it's almost all single threaded blocking usage of sockets).
> Under what circumstances can send() return a smaller number?
Just open a TCP/IP connection and send huge (64K or so)
buffers. Current Python behavior is no different than C on
Linux, HPUX and Windows.
Look it up in Stevens if you don't believe me. Or try it.
- Gordon