When the other side closes a socket, select returns read available for that
socket, so the readable socket set should have the corresponding bit set.
When you read the corresponding socket, you will read 0 bytes, which means
that the connection is closed, so you are supposed to close that socket.


Tuan Hoang wrote:

> Hi,
>
> I have a single threaded process that is a basic TCP server.
> I use select() in order to not block when I read data from
> the client so I can do other things if no data is available.
> It only reads data and does NOT send anything to the client.
> (from the application layer anyway).
>
> Well, I've run into the case where if the client mysteriously dies
> and select() on reading does not return an error.  It returns 0 which
> is correct because the file descriptor is still valid from
> the server's point of view and there is no data to be read.
> The server just continues on like the client is still connected but
> in fact it is not.
>
> Aside from handling SIGPIPE, is there something else that I could do
> to check for a terminated client?
>
> Thanks,
> Tuan
>
> --
> Tuan Hoang
> The MITRE Corporation
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-net" in
> the body of a message to [EMAIL PROTECTED]



-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to