|
| I have client and server connected.
client write and read from csock.
server write and read from ssock
suppose the server does :
.....
close(ssock); //send FIN to client
othertask();
.....
READ ERROR
if after the server close() the client does:
....
read(csock,...);
....
read(csock,...);
....
close(csock,...);
....
read(csock,...);
....
first read return 0 (read FIN)
second read also return 0.
third read return -1 with errno set to EBADF.
QUESTION 1:
Indeed if after the server close() the client does:
.....
write(csock, "hello", 6); //server send RST
....
read(csock,...);
....
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?
IS THE SITUATION THE SAME WHEN THE SERVER CRASH BEFORE THE CLIENT'S
FIRST WRITE?
QUESTION 2:
when read fails with errno=ENOTCONN?
QUESTION 3:
In general if I don't set the timeout option, is possible that a
read() fails with errno=ETIMEDOUT?
WRITE ERROR
when write fails and errno =ECONNRESET??
| |