Skip to content Skip to sidebar Skip to footer

Can Reactor.connecttcp Occur After Reactor.run In Twisted Python?

I wish to add more protocols and factories after reactor runs. I couldn't find documentation which says this is allowed. When I make reactor.run before reactor.connectTCP, the prog

Solution 1:

Yes, you can start or stop listening on a TCP port at any time in Twisted. However, code like

reactor.run()
reactor.listenTCP(...)

won't work because run() only returns when the reactor has been stopped and the program is ready to exit. So you need to call listenTCP in response to something.

Also, don't use listenTCP directly; it's a very low-level API. Instead, use Endpoints.

Post a Comment for "Can Reactor.connecttcp Occur After Reactor.run In Twisted Python?"