[Twisted-Python] Limiting number of concurrent client connections
exarkun at divmod.com
Tue Jun 28 10:10:52 EDT 2005
On Tue, 28 Jun 2005 10:47:04 +0100, Toby Dickenson <tdickenson at devmail.geminidataloggers.co.uk> wrote:
>Im finding that Win32Reactor raises an exception on every iteration of the
>main loop if I exceed the limit of 64 WaitForMultipleObjects.
>I would prefer to avoid this fairly obvious denial-of-service problem by
>limiting the number of concurrent client connections. Is there a standard
>solution for this?
Count the number of connections you have accepted. When you get up to 62 or 63 or so, stop accepting new ones. If ServerFactory.buildProtocol() returns None, Twisted immediately closes the accepted connection. If you do this (perhaps in conjunction with calling stopListening() on the port returned by listenXYZ()), you'll never overrun the 64 object limit.
More information about the Twisted-Python