First, a little background to explain the motivation: I\'m working on a very simple select()-based TCP \"mirror proxy\", that allows two firewalled clients to talk to each
You could check if the socket is still connected by trying to write to the file descriptor for each socket. Then if the return value of the write is -1 or if errno = EPIPE, you know that socket has been closed.
for example
int isSockStillConnected(int *fileDescriptors, int numFDs){
int i,n;
for (i=0;i