I'm writing a server which serves multiple clients connected to it via
sockets. Basically the server keeps a list of open sockets, and
periodically it'll write() a message on all the sockets in the list. If a
client crashes or otherwise closes the connection, my server would like to
know about it so that it can remove that socket descriptor from its list of
open sockets. How can the server query the state of a soocket?
What I'm doing now is calling select(&read_fds, &write_fds, &except_fds,
&timeval) and examining the value of write_fds. After one chunk is written
to a broken connection, select determines that another write will block and
so that fd is removed from write_fds. I don't think this is the way I'm
supposed to do it.
When will an exception ever be raised on a socket? Is that what I'm
looking for? The description in Unix Network Programming didn't clarify
what exactly could cause an exception.
Thanks in advance, any suggestions appreciated.
Tessa Lau