Xiaodan Tang(deleted)
06/06/2008 5:05 PM
post8858
|
> You should be able to adjust the timers per socket with TCP_KEEPALIVE,
> struct timeval being defined in sys/time.h.
>
> One thing that you may have to watch for is that not all socket options
> are inherited by the accept()ing socket. You may have to set the option
> against the socket returned by accept() rather than the listening
> socket.
>
> Dave
Dave is correct. TCP_KEEPALIVE is per socket, so you have to set it on the socket returned by accept(), not the listen
one.
Also, TCP_KEEPALIVE only changes when should a KEEPALIVE packet send out. But it still take the standard TCP timeout
time to decided drop the connection. Ie, if you set TCP_KEEP_ALIVE to, say 10 seconds; then after 10 seconds the first
KEEPALIVE packet would send out, if no reply, it will resend ..., and (if I remember correct) it takes another 9.5
minutes to decided the other side is not there, and then the connection dropped.
|
|
|