<!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 <<a
href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">rob.mason at ammeon.com</a>> wrote:
>><i>Hi ,
</i>><i>>I am using twisted to write a test client to interface with a server running
</i>><i>>a bespoke protocol.
</i>><i>>The server expects interactions from the client something like:
</i>><i>>attach
</i>><i>> sendMessage
</i>><i>> sendMessage
</i>><i>> .
</i>><i>> .
</i>><i>> .
</i>><i>> unattach
</i>>><i>
</i>><i>>If the server does not receive a specific unattach from the client , it will
</i>><i>>maintain a resource open for the client even though there is no connection.
</i>><i>>Eventually the server will refuse additional connections (once it's number
</i>><i>>of 'open' connections exceeds some limit).
</i>
> 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!
>><i>
</i>><i>>I want my client to be able to send an 'unattach' message before closing.
</i>>><i>
</i>><i>>Is there a way I can override the default reactor behaviour in handling e.g.
</i>><i>>SIGINT so that I can force my client to send the unattach message before
</i>><i>>proceeding with normal reactor sigint handling?
</i>
>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:
> reactor.addSystemEventTrigger('before', 'shutdown', f)
>Twisted includes a service system which takes advantage of this feature, which you may want to use instead. See <<a
href="http://twistedmatrix.com/projects/core/documentation/howto/application.html">http://twistedmatrix.com/projects/core/documentation/howto/application.html</a>>, which mostly talks about servers, but clients are approximately the same.
Thanks , I will try this.
>Jean-Paul</pre>
</body>
</html>