write will return how many bytes it has written to the socket.
Keep track of it.
Feel free to ask further.
Chialin> The problem that I have now is that with a stream socket
Chialin> (SOCK_STREAM), if the client does not drain the socket fast
Chialin> enough, a non-blocking write on the server side could just
Chialin> write a portion of the message, return -1 and set errno to
No. This can't happen (barring serious kernel bugs).
A write() to a non-blocking socket can return:
- the number of bytes successfully written, which may be less than
the number requested
- -1 with EAGAIN or EWOULDBLOCK, which indicates that *no* data has
comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
I try to build up a program structure consisting of a couple of client
communicate to each other using sockets. The communication is managed by
process. The programs are written in C based on a LINUX-platform. (I
hope You UNIX
programmers are also able to give me a hint.)
When sending a long message to another program (should be up to 1 MByte)
check weather the connection line is able to receive data (SELECT).
Then the WRITE statement transmits the first portion to the socket
waits until the target program reads the data from the buffer.
If the target program is busy that moment, the sending program is
so my question:
Is it possible to find out the size of the socket buffer (which differs
from one WRITE
to the other) and the remaining space in the buffer ?
(so I can write only the exact number of bytes without WRITE-blocking)
thanx a lot
7. HELP ERROR