I have an existing program that connects to a TCP port to serve data. I need to
1) start a TCPServer 2) start my program and tell it which port to connect to Actually, I want to do all this in twistd. And now I am looking at something like this which is even a bigger headache internet.TCPServer( 4321, serverFactory ),setServiceParent(serviceCollection) I revise my question. Can I rely on reactor.listenTCP being called right after serverFactory.startFactory is called? I hope listenTCP isn't queued as a reactor "task" after serverFactory.startFactory. If it's done all in one uninterrupted thread execution, then I can just queue "start_the_other_program" inside startFactory via a reactor.callLater. Correct? Enrique, thanks for the link. I think I saw that too. I traced it since reactor.listenTCP returns a port, and so on and so forth. However, I have not been able to find code for internet.TCPServer. I would like to be able to trace the code top down. Can someone help? Thanks! David Kao On Tue, Sep 27, 2011 at 5:12 PM, Enrique Samson Jr. <[email protected]> wrote: > On Tue, Sep 27, 2011 at 4:33 PM, David Kao <[email protected]> wrote: >> >> When the call to listenTCP returns, is the server actively waiting for >> TCP connections? > > Looking at the code here, I would think so. > >> >> Let's say reactor.run() has been called. Can I do the following >> back-to-back? >> >> reactor.listenTCP(4321, serverfactory) >> reactor.connectTCP("localhost", 4321, clientfactory) >> >> Basically, I am almost starting a server and a client back-to-back >> that connects to each other. > > Just curious, why are you doing this? > >> >> I would like to know if the server is in >> "listening" state before my client attempts to connect. >> >> Thanks. >> >> David Kao > > --Enrique > > _______________________________________________ > Twisted-Python mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > _______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
