the client writes 5 bytes to the socket after every 1 second. the server continuously reads from the socket. the buffer at the server end is 10 bytes long. so the function looks like this
read(fd, buf, 10);
the server reads 5 bytes everytime.
now the client writes 5 bytes continuously. the server is the same. the server reads 10 bytes everytime.
so is it that the read on a socket returns as many bytes as available in the buffer. it does not wait to fill up the buffer.
does it have something to do with SO_RCVLOWAT. i read that this socket option only has an effect in select/poll io.
thanks
update:
i changed SO_RCVLOWAT to 10, now it waits for 10 bytes at least in the receive buffer. so it seems it does have something to do with the low water mark of the receive buffer.
but i cannot set the low watermark to 0. it always sets it to 1 in that case. why is it so?