[Twisted-Python] How to set client timeout with reactor.listenTCP?

Jean-Paul Calderone exarkun at divmod.com
Mon Jun 23 10:46:32 EDT 2008

On Mon, 23 Jun 2008 22:36:45 +0800 (CST), uupandemo <uupandemo at 126.com> wrote:
> def main():
>    port=8008
>    reactor.listenTCP(port,policyServerFactory())
>    reactor.run()
>$ telnet localhost 8008
>Connected to policy.126.com (
>Escape character is '^]'.
>Client will not close the connect unit it disconnects itself. But the server can't control the connect. In some critical environment, the server has to maintain a lot of connect which maybe is idle.
>So I want to the server initiative disconnect the idle connection reache timeout.

You might find twisted.protocols.policies.TimeoutMixin helpful.  Use it
with your protocol implementation to define arbitrary behavior to be run
after the client has been idle for a period of time you define.


More information about the Twisted-Python mailing list