For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > April 2007 > read/write error on socke









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author read/write error on socke
gio

2007-04-06, 7:07 pm

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??

Bizzle

2007-04-12, 11:42 am

http://Angelina-Jolie-doing-it.info...hp?movie=148803
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com