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

Jean-Paul Calderone exarkun at divmod.com
Mon Jun 23 08:46:32 MDT 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
>Trying 127.0.0.1...
>Connected to policy.126.com (127.0.0.1).
>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.

Jean-Paul




More information about the Twisted-Python mailing list