Re: Q about low lvl UNIX socket programming

From: Richard B. Johnson (
Date: Thu Apr 27 2000 - 10:25:09 EST

On Thu, 27 Apr 2000, [ISO-8859-1] Jerry Lundström wrote:

> Q: How can I check (using portable standards) how much is used in the
> buffers (send/recv) of a UNIX socket fd?
> Q: If that can't be done, how can I make send/write write the entire
> message or not at all (iow, do NOT splitt the message) in NONBLOCKing
> mode?
> I agree that this may not be the correct list for such questions and
> if you know a better list please let me know.

Any program that uses a stream of data for I/O, and a socket is a
stream, has to be prepared to send portions of data especially if
it is intended to be portable.

In principle, a send() or write() with a data-length of 0x1000 could
return 0x0001. It's unlikely, but portable programs have to handle it.

Even messing with socket options "setsockopt(SO_SENDBUF,,,SO_SNDLOWWAT",
etc., will not guarantee that your data will be sent all-at-once.
Do not write communications programs that presume anything like that.

Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:13 EST