My client program processes data locally, but periodically checks for
new data from the server on an established socket connection. I use
select() for possible timeouts prior to a read(), but select() won't
tell me if the server goes away (ie the AUI cable is yanked).
I attempted to use setsockopt() and the SO_KEEPALIVE option to determine
whether I have a valid socket connection. Unfortunately I haven't had
In my testing, I get a socket descriptor, make a connection to the server,
and then use setsockopt();
int toggle = 1;
setsockopt(sockfd,SOL_SOCKET,SO_KEEPALIVE,(char *) &toggle,sizeof(toggle));
(setsockopt() returns a zero. Also, I tried using setsockopt() prior to
making the connection, but it made no difference).
To test for a broken connection, I physically disconnect the AUI cable
on the server side, and on the client side I process data for a few minutes
and then attempt to read data whereby I timeout properly from using the
select() call. However, so_error should be set to ETIMEDOUT from using
setsockopt(), but remains set at zero. Any help would be appreciated.