Why do Windows sockets break after exactly 4 minutes?

Grant Edwards grante at visi.com
Thu Mar 21 21:17:13 EST 2002


In article <3C9A7C83.F61ECDD1 at engcorp.com>, Peter Hansen wrote:
> Geoffrey Talvola wrote:
>> 
>> I've noticed that Windows sockets seem to close all by themselves if there
>> is no activity for 4 minutes.  Does anyone know why?

> Haven't run your tests, but isn't this what SO_KEEPALIVE is used for?

No.  If SO_KEEPALIVE is set, then the TCP layer will send
"pings" (which are actually just bogus ACKs, IIRC) back and
fourth to make sure the link is still there.  If the cable is
pulled or the interface goes down, then the SO_KEEPALIVE option
will detect this and shut down the socket.

It will only close the socket if the link is physically broken.
It doesn't care whether or not there is user data going back
and forth.

-- 
Grant Edwards                   grante             Yow!  Where's the Coke
                                  at               machine? Tell me a joke!!
                               visi.com            



More information about the Python-list mailing list