[Twisted-Python] Limiting the number of connections
adi at roiban.ro
Sun Dec 9 04:44:11 EST 2012
On 9 December 2012 02:17, Miha Valencic <miha.valencic at gmail.com> wrote:
> I have developed a simple twisted tcp server which does ldap lookups
> as a result of user input. I would like to limit the number of
> connections each listener (I have 4, each on its own port) accepts. I
> guess people usually want to accept as many connections as possible,
> but I would like to limit them.
> From what I've read (a single post from 2009):
> "As you observed, doing this on the server accepts and then
> immediately closes the connection. There is no way to not accept the
> connection. This is a limitation of the underlying platform APIs."
> Is this still the case? We can't limit the number of accepted connections?
Just to summarize:
* twisted.protocols.policies.LimitTotalConnectionsFactory is not what
you want since the server is still listening on the port?
LimitTotalConnectionsFactory is only returning a different protocol to
handle the overflow.... closing the new connection is a way to handle
* After a number of connections the server should stop listening on
the port... and then tor re-start listening after the connections are
More information about the Twisted-Python