The keepalive would cause the connection to be always alive when you close
the socket. That means that the shut-down handshake has always to be done
when calling closesocket or shutdown. This is different from an application
without keepalive where the server could have already performed the shutdown
well before the client closes the socket. In that case closing the socket is
not in the background but immediate.

Regarding the virus, take a look at this:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5069989 . The short
version: if an application spawns another process, the process inherits also
the socket handle. The socket isn't closed until both processes quit or
release the socket. I've seen somewhere a demo of the problem where an app
launches notepad, closes a socket and quits. The socket remains open as long
as notepad runs!! Running an app from in an IDE or debugging environment
could also lead to this type of problem.

> I don't know (since I'm closing down I don't check the error)

There is something going wrong with closing the socket. Looking at the error
could give an indication... The closing handshake is only part of the
closesocket process.

Ludo


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


Al 25/05/11 21:42, En/na Ludo Brands ha escrit:
> 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.

If there's any remaining data, it should send that, not keepalive packets,
shouldn't it? I saw the retries in the shutdown handshake when I pulled the
cable, even after I closed the application, and I find that normal.

> The "in the
> background" could mean that this could take a while and not finished 
> when the app is already closed.

It was a very long while and, again, I think it should send either the
remaining data (there was none, BTW) or try to tear down the connection, not
sending keepalive packets.

> Could also explain the fact that the problem is
> not always repeatable.
> 
> The additional CloseSocket doesn't return an error?

I don't know (since I'm closing down I don't check the error), but I see two
FIN on the wire (both acknowledged by the peer).

BTW, I later discovered that the computer was infected with conficker, 
I don't know if that's relevant or not.

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