in reply to Re^2: Maintain TCP client connection to server?
in thread Maintain TCP client connection to server?
What can_write() can really tell you is if the server has closed its connection in a clean way, i.e. sending you a FIN packet that your TCP stack has diligently ACKed, which is the best you can get now.
Changing the system won't help you much, so I'm inclined to tell you that you will not know that your connection is down so fast. Any TCP implementation is based on the fact that the underlying network protocol (i.e. IP) can generate delays that are virtually indistinguishable from network failures; in fact, TCP usually adopts some retry schemes for packets that are not acknowledged, so you definitively have to wait.
Moreover, to check if the server is down you actually have to force the TCP/IP stack to send something to him and have it unacknowledged, and I fear that any implementation is "smart" enough to need real data to make such a check. But here I'm going too deep into the forest, and I don't have the needed light at the moment to make the matter clearer - try to ask to some TCP expert forum, or to read about the TCP implementation in the Linux Kernel.
Flavio
Don't fool yourself.
|
|---|