I used this snipped of code to enable tcp keepalives under windows (xp, 32 bits): (FChannel is a TTCPBlockSocket):
FChannel.Connect(FAddress,Fort); if FChannel.LastError=0 then begin DoLog(LogInfo,'connected'); FConnected:=true; keepalive.onoff:=1; keepalive.keepalivetime:=10000; keepalive.keepaliveinterval:=1000; if wsaioctl(FChannel.Socket, SIO_KEEPALIVE_VALS, @Keepalive, sizeof(Keepalive), nil, //lpvOutBuffer 0, //cbOutBuffer @dummy, //lpcbBytesReturned nil, //lpvOverlapped nil //lpCompletionRoutine ) = 0 then DoLog(LogInfo,'set a keepalive of 10 seconds'); This code works (though the keepalive is sent after 1 second of inactivity and not 10), but I found a strange problem: when I closed the program, windows kept the socket open and kept sending keepalives (I saw it with wireshark, sysinternals' tcpview showed the socket as owned by a non existent process). This doesn't happen always (I cannot reproduce the problem at will) but it happens. The problem is that the peer only accepts one connection, so I cannot reconnect when I start the program again if windows is keeping the socket open behind my back. I know that this isn't a synapse problem, but here is where the experts are ;-), so, is this normal? If I, say, disconnect the cable and close the program, I find it normal for windows to keep the socket around so that it can tear down the connection when the cable is reconnected, but I think it's strange that it keeps sending keepalives. Bye -- Luca ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ synalist-public mailing list synalist-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synalist-public