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

Fredrik Lundh fredrik@pythonware.com
Fri, 11 Aug 2000 15:55:01 +0200


guido wrote:

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?

never, it seems:

The length of the message to be sent is specified by the
length argument. If the message is too long to pass through
the underlying protocol, send() fails and no data is transmitted.

Successful completion of a call to send() does not guarantee
delivery of the message. A return value of -1 indicates only
locally-detected errors.

If space is not available at the sending socket to hold the message
to be transmitted and the socket file descriptor does not have
O_NONBLOCK set, send() blocks until space is available. If space
is not available at the sending socket to hold the message to be
transmitted and the socket file descriptor does have O_NONBLOCK
set, send() will fail.

(from SUSv2)

iow, it either blocks or fails.