Forum Discussion
Altera_Forum
Honored Contributor
14 years agoI never used the KEEPALIVE options.
In cases similar to yours I manage the issue in an alternate way, allowing the server to force closing the connection when the client is no longer using it. Since you use the SimpleSocketServer example, this can be easily done by setting to FALSE the state field of SSSConn struct. Just remember to save the SSSConn pointer to a static copy when the connection is established, so that you can use it when you need it. Which way you use to detect the 'dead connection' condition (and then force it to close) depends on your application. For example you can define your application communication protocol so that you add dummy data transfers which act as keep alive messages. If server doesn't receive at least one of them after a predefined time, it closes the connection in the above manner. Another option I sometimes used, is to use an additional socket on another port whose only purpose is to act as backdoor to unlock the main connection. This is not the best solution, but it has the advantage it is very easy to implement. Regards