Re: Recv(), determining connection closed or broken
From: Umpa (¹¿æó_at_umpaumpalala.com)
Date: Tue, 18 May 2004 10:25:12 +0200
> If your side knows that the other side closed the connection normally,
> 'recv' will return zero. If your side knows that an error has occured
> (either locally or on the other side), 'recv' will return '-1' and 'errno'
> will tell you want happened.
Here are errnos matched to recv():
The argument s is an invalid descriptor.
A remote host refused to allow the network connection
(typically because it is not running the requested service).
The socket is associated with a connection-oriented protocol
and has not been connected (see connect(2) and accept(2)).
The argument s does not refer to a socket.
The socket is marked non-blocking and the receive operation would
block, or a receive timeout had been set and the timeout expired before
data was received.
The receive was interrupted by delivery of a signal before any
data were available.
The receive buffer pointer(s) point outside the process's address space.
Invalid argument passed.
Please, do tell me what errno is set to when connection
is broken during receiving ? Personally, I can`t see any.
How about this: