SO_LINGER has some side effects in closing a socket. From
http://msdn.microsoft.com/en-us/library/ms737582%28v=vs.85%29.aspx: If the
l_onoff member of the LINGER structure is zero (the default for a socket),
closesocket returns immediately and the connection is gracefully closed in
the background.
Gracefully means sending remaining data and shutdown handshake. The "in the
background" could mean that this could take a while and not finished when
the app is already closed. Could also explain the fact that the problem is
not always repeatable.

The additional CloseSocket doesn't return an error?

Ludo


-----Message d'origine-----
De : Luca Olivetti [mailto:l...@ventoso.org] 
Envoyé : mercredi 25 mai 2011 20:52
À : Ararat Synapse
Objet : Re: [Synalist] RE : tcp keepalive under windows, strange problem.


Al 25/05/11 20:43, En/na Luca Olivetti ha escrit:
> Al 25/05/11 18:33, En/na Ludo Brands ha escrit:
>> Stupid question:
> 
> Not stupid, maybe it's the cause of the problem
> 
>> do you close the socket before quiting the application? Shutdown 
>> followed by CloseSocket? Or just CloseSocket? What SO_LINGER option 
>> is used?
> 
> I call a TTCpBlockSocket.AbortSocket outside the thread, and an 
> additional CloseSocket (just in case) before returning from the 
> Execute loop. TTCPBlockSocket.AbortSocket calls 
> TTCPBlockSocket.CloseSocket and TTCPBlockSocket.CloseSocket calls 
> Shutdown internally. I don't set SO_LINGER, so it's at its default 
> value (whatever that is).

Now that I think of it, if there were some data to send, there would have
been no need to send keepalive packets, so I think that the SO_LINGER
setting doesn't matter for the issue at hand.

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


------------------------------------------------------------------------------
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

Reply via email to