[Twisted-Python] How can a tcp client connect with multi servers?
xuryans at gmail.com
Thu Dec 1 22:42:49 EST 2005
Would you like show me an simple example about this? I wrote one, but
it dosn't work.
__sender = None
print "Connecttion make"
def connectionLost(self, reason):
print "Lost, reason", reason
def sendCmd(addr, port, cmd, task, options = ""):
"""Send Cmd to
cmd, task, options)
def send(p,cmd, task, options):
if not __sender:
__sender = ClientCreator(reactor, p)
if __name__ == "__main__":
sendCmd("localhost", 8009, "test send")
On 12/1/05, Andrew Bennetts <andrew-twisted at puzzling.org> wrote:
> You seem to misunderstand how to do concurrent operations in Twisted. You don't
> need to stop the reactor. If at some point in your code you want to make
> another connection with ClientCreator, just call ClientCreator's connectTCP
> method as usual -- without stopping the reactor. The point of the reactor is
> that it takes care of managing multiple connections and the like at once.
> So, it's not "stop [the reactor] , re-create ClientCreator, then call
> reactor.run() to send the message", it's just "re-create ClientCreator". It may
> even be just "call connectTCP on your existing ClientCreator again."
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python