<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 18, 2013, at 1:59 PM, Bob Novas <<a href="mailto:bob.novas@shinkuro.com">bob.novas@shinkuro.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">I’ve got a question on how to explicitly disconnect a connection from the client side so that the server side knows that the connection has been disconnected. I’d be happy if this worked even with no guarantees, i.e., only when the client and server were in fact well-connected. It’s just an optimization to allow the server to cleanup.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">I’ve got an HTTP client that uses HTTPConnectionPool to get an Agent, gets a Request from the Agent, and sends the Request to a WebServer on a linux box. <o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">On a Mac client, if I call closeCachedConnections() on the HTTPConnectionPool, the client immediately sends FIN on the port with the Request outstanding, the server delivers a callback registered on the Request via NotifyFinish() and the server knows the client has disconnected.</div></div></div></blockquote><div><br></div><div>Sounds right...</div><br><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> </span><span style="font-size: 11pt;">On a Windows client, if I do the same, same code, the client waits until the outstanding Request finishes and then sends FIN. Nothing happens at the server – there’s no Request outstanding on which to deliver a callback, twisted.internet.tcp.Port.connectionLost() doesn’t get called, nada.</span></div></div></div></blockquote><div><br></div><div>So, tcp.Port.connectionLost is only called when the *listening port* is shut down, i.e. when the server stops listening entirely.  What you should be looking for is connectionLost on your particular Protocol.</div><br><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p><span style="font-size: 11pt;">Am I missing something?  Is there a way to send a FIN on a connection on which there is an outstanding Request on Windows?</span></div></div></div></blockquote><div><br></div><div>Twisted should behave the same way on all platforms, at least, if you're using portable APIs.</div><div><br></div><div>Usually, when the TCP stack completely goes out to lunch on Windows, it's due to some bizarre antivirus software that's just buggy.  For a while, possibly still today, Twisted just completely dies with certain versions of AVG installed, because they completely break the expected behavior of certain socket APIs.</div><div><br></div><div>Have you tried with multiple Windows clients yet? Different versions of Windows? Different software installed?</div><br></div><div>-glyph</div><br></body></html>