[Twisted-Python] Limiting the number of connections
itamar at itamarst.org
Sun Dec 9 07:57:16 EST 2012
On 12/09/2012 05:31 AM, Miha Valencic wrote:
> No, the server shouldn't accept() the socket after n connections are
> opened(). But see previous paragraph.
You can stop accept()ing by calling stopReading() on the returned port
port = reactor.listenTCP(....)
And start again by calling startReading().
- When you are accept()ing, it will accept() a few at a time.
- Even if you stop accept()ing, the OS will still do TCP handshakes,
approximately up to a limit determined by one of the arguments passed to
- After hitting the limit, clients will get connection refused, IIRC.
In general it's better to do a protocol-level solution, as Adi Roiban
More information about the Twisted-Python