Documentation in man 2 send about blocking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have a few questions about the send() syscall and its man page, reproduced below.

In normal usage (blocking mode), send() blocks, but doesn't guarantee that all bytes in the buffer are sent on success, right? In particular, are there cases where a blocking send() "succeeds" while returning an integer smaller than the length of the buffer?

In nonblocking mode, the man page says that send() "would fail" if the message is long, and then I might interpret the "Return value" paragraph to imply that it returns -1. However a simple test in that case shows that send() returns the number of bytes sent, which is certainly a sensible thing to do, pragmatically. Am I missing something in my interpretation, or could the docs be reworded to better reflect the actual behavior of send()?

Regards,
Li-yao

---

Excerpt from man 2 send, source: http://man7.org/linux/man-pages/man2/sendmsg.2.html

       When the message does not fit into the send buffer of the socket,
       send() normally blocks, unless the socket has been placed in
       nonblocking I/O mode.  In nonblocking mode it would fail with the
       error EAGAIN or EWOULDBLOCK in this case.  The select(2) call may be
       used to determine when it is possible to send more data.

       ...

    Return value

       On success, these calls return the number of bytes sent.  On error,
       -1 is returned, and errno is set appropriately.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux