[Python-Dev] noreply@sourceforge.net: [Python-bugs-list] [Bug #111620] lots of use of send() without verifyi ng amount of data sent.

Guido van Rossum guido@beopen.com
Fri, 11 Aug 2000 09:19:33 -0500


> > I just noticed this.  Is this true?  Shouldn't we change send() to
> > raise an error instead of returning a small number?  (The number of
> > bytes written can be an attribute of the exception.)
> 
> This would break a lot of code. (probably all that use send, with or without
> return-code checking.) I would propose a 'send_all' or some such instead,
> which would keep sending until either a real error occurs, or all data is
> sent (possibly with a timeout ?). And most uses of send could be replaced by
> send_all, both in the std. library and in user code.

Really?!?!

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.

Under what circumstances can send() return a smaller number?

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)