according to my knowledge it's not easy , but sometimes we send a probe periodically to make sure the client is alive , after trying the probe for several times if we still didn't receive a reply from the client we assume the client is no longer alive and the connection is terminated, but still this doesn't say exactly it is because of network failure,
but i think your problem can be solved using socket options in c or c++
this might help you keepalive
http://docs.hp.com/en/B2355-90136/ch03s01.html[
^]