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

When a client to the server socket, server can't close the connection while the idle time exceed the timeout. How to solve it?

On Mon, 23 Jun 2008 11:37:33 +0800 (CST), uupandemo <uupandemo@126.com> wrote:
When a client to the server socket, server can't close the connection while the idle time exceed the timeout.
How to solve it?
When a client does what? Why can't the server close the connection? Can you clarify the question a bit? Perhaps you can include a minimal runnable example that demonstrates the problem. Jean-Paul

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. 在2008-06-23 19:33:35,"Jean-Paul Calderone" <exarkun@divmod.com> 写道:
On Mon, 23 Jun 2008 11:37:33 +0800 (CST), uupandemo

On Mon, 23 Jun 2008 22:36:45 +0800 (CST), uupandemo <uupandemo@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
participants (2)
-
Jean-Paul Calderone
-
uupandemo