<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>On Tue, 31 Jan 2006 11:43:02 +0000, Rob Mason &lt;<a
 href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">rob.mason at ammeon.com</a>&gt; wrote:
&gt;&gt;<i>Hi ,
</i>&gt;<i>&gt;I am using twisted to write a test client to interface with a server running 
</i>&gt;<i>&gt;a bespoke protocol.
</i>&gt;<i>&gt;The server expects interactions from the client something like:
</i>&gt;<i>&gt;attach
</i>&gt;<i>&gt;        sendMessage
</i>&gt;<i>&gt;        sendMessage
</i>&gt;<i>&gt;          .
</i>&gt;<i>&gt;          .
</i>&gt;<i>&gt;          .
</i>&gt;<i>&gt;  unattach
</i>&gt;&gt;<i>
</i>&gt;<i>&gt;If the server does not receive a specific unattach from the client , it will 
</i>&gt;<i>&gt;maintain a resource open for the client even though there is no connection.
</i>&gt;<i>&gt;Eventually the server will refuse additional connections (once it's number 
</i>&gt;<i>&gt;of 'open' connections exceeds some limit).
</i>
&gt;  Is it intentional that resource allocation is independent of actual TCP connections?  If not, perhaps you just want to clean things up when a connection is lost.  You may also want to use a TCP or app-level keep alive so as to notice connections lost due to network problems.

It is intentional in the design of the server protocol, and the protocol supports a keep alive PDU!

&gt;&gt;<i>
</i>&gt;<i>&gt;I want my client to be able to send an 'unattach' message before closing.
</i>&gt;&gt;<i>
</i>&gt;<i>&gt;Is there a way I can override the default reactor behaviour in handling e.g. 
</i>&gt;<i>&gt;SIGINT so that I can force my client to send the unattach message before 
</i>&gt;<i>&gt;proceeding with normal reactor sigint handling?
</i>
&gt;You don't actually care about SIGINT, just shutdown.  The lowest level hook available for this is the shutdown system event, which can receive notification of via:

&gt;   reactor.addSystemEventTrigger('before', 'shutdown', f)

&gt;Twisted includes a service system which takes advantage of this feature, which you may want to use instead.  See &lt;<a
 href="http://twistedmatrix.com/projects/core/documentation/howto/application.html">http://twistedmatrix.com/projects/core/documentation/howto/application.html</a>&gt;, which mostly talks about servers, but clients are approximately the same.

Thanks , I will try this.

&gt;Jean-Paul</pre>
</body>
</html>