[Twisted-Python] Limiting the number of connections

Adi Roiban adi at roiban.ro
Sun Dec 9 08:25:07 EST 2012

On 9 December 2012 15:14, Adi Roiban <adi at roiban.ro> wrote:
> On 9 December 2012 14:57, Itamar Turner-Trauring <itamar at itamarst.org> wrote:
>> 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
>> object:
>> port = reactor.listenTCP(....)
>> port.stopReading()
>> And start again by calling startReading().
> [snip]
> Many thanks for you explanation.
> Checking the documentation I can read that reactor.listenTCP returns
> an IListeningPort [1]
> Checking IListeningPort I can read that it has no stopReading() ,
> startReading() methods [2]
> Can you please advise how and when to use startReading vs startListening ?

I would like to rephrase my previous question:

I understood that stopListening() is closing the listening socket,
while stopReading does not closed the listening socket, but rather
stops from handling new connection using the attached factory ... and
new connections are queued in the backlog.

What interfaces defines startReading/stopReading for a TCP Port?


Adi Roiban

More information about the Twisted-Python mailing list