On Apr 6, 12:13 pm, "gio" <giorginooo.ro...@yahoo.it> wrote:
> QUESTION 1:
> Indeed if after the server close() the client does:
> write(csock, "hello", 6); //server send RST
> write(csock, ...);
> first write return 6 without signaling nothing.
> read return:
> 0 if the client read before the RST arrives.
> -1 with errno set to ECONNRESET otherwise.
> second write comports the SIGPIPE signal.
> if it is ignored write return -1 and errno=EPIPE, otherwise it
> comports the client termination.
> is ok?
I'm not sure what you're asking.
> IS THE SITUATION THE SAME WHEN THE SERVER CRASH BEFORE THE CLIENT'S
> FIRST WRITE?
Again, I'm not sure what you're asking.
> QUESTION 2:
> when read fails with errno=ENOTCONN?
Read will fail with ENOTCONN when you pass a socket that must be
connected in order for data to be read (such as a TCP socket) that is
not connected. For example, if a non-blocking 'connect' is in
> QUESTION 3:
> In general if I don't set the timeout option, is possible that a
> read() fails with errno=ETIMEDOUT?
Yes. A 'read' function will block for as long as it takes for data to
arrive. If while waiting for data to arrive, the TCP connection times
out, the 'read' function will return ETIMEDOUT. There are at least two
ways this can happen. One is if a 'write' is still in progress when
you call 'read' -- if that 'write' times out, the TCP connection times
out. Another is if you have TCP keep alives enabled.
> WRITE ERROR
> when write fails and errno =ECONNRESET??
When the connection has been reset by the other end. This can happen
if the other end reboots and the new instance of the OS has no idea
that the connection ever existed. It can also happen if the other side
closes the connection without reading all data.