[Twisted-Python] connection to many servers

Hi, i need to connect to many servers so i've found an example that shows how to connect to many servers see the source below. But i need to get the way to retrieve each server in order to see the satus of the connection, to send to it a message. Is there an connection object with sendData action, getCxStatus for example Thanks class ClntProtocol(protocol.Protocol): def sendData(self, data): if data: self.transport.write(data) else: self.transport.loseConnection() def connectionMade(self, data=''): connectedClientlist.append(self) if data: self.sendData(data) def dataReceived(self, data): if data: self.sendData(data) def closeConnection(self): pass class cxFactory(protocol.ClientFactory): protocol = ClntProtocol def __init__(self): self.deferred = defer.Deferred( ) def clientConnectionFailed(self, connector, reason): self.deferred.errback(reason) def svcConnect(address): clntFactory = cxFactory() reactor.connectTCP(address[0], int(address[1]), clntFactory) return clntFactory.deferred def connectAll(addresses): logger.info("connect all") servers = [svcConnect(address) for address in addresses] defer.DeferredList(servers, consumeErrors=True).addCallback(handleAllResults, addresses) reactor.run( )

On 09:40 am, dbcourriel-4all@yahoo.fr wrote:
The protocol instance is that object. In your case, the ClntProtocol (I hope that you profited well by omitting "ie" from that name). If you want to keep track of multiple connections, I suggest a list or dictionary. Jean-Paul

Thanks a lot for your answer. regards, --- En date de : Mar 7.9.10, exarkun@twistedmatrix.com <exarkun@twistedmatrix.com> a écrit : De: exarkun@twistedmatrix.com <exarkun@twistedmatrix.com> Objet: Re: [Twisted-Python] connection to many servers À: "Twisted general discussion" <twisted-python@twistedmatrix.com> Date: Mardi 7 septembre 2010, 14h52 On 09:40 am, dbcourriel-4all@yahoo.fr wrote:
The protocol instance is that object. In your case, the ClntProtocol (I hope that you profited well by omitting "ie" from that name). If you want to keep track of multiple connections, I suggest a list or dictionary. Jean-Paul -----La pièce jointe associée suit----- _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

On 09:40 am, dbcourriel-4all@yahoo.fr wrote:
The protocol instance is that object. In your case, the ClntProtocol (I hope that you profited well by omitting "ie" from that name). If you want to keep track of multiple connections, I suggest a list or dictionary. Jean-Paul

Thanks a lot for your answer. regards, --- En date de : Mar 7.9.10, exarkun@twistedmatrix.com <exarkun@twistedmatrix.com> a écrit : De: exarkun@twistedmatrix.com <exarkun@twistedmatrix.com> Objet: Re: [Twisted-Python] connection to many servers À: "Twisted general discussion" <twisted-python@twistedmatrix.com> Date: Mardi 7 septembre 2010, 14h52 On 09:40 am, dbcourriel-4all@yahoo.fr wrote:
The protocol instance is that object. In your case, the ClntProtocol (I hope that you profited well by omitting "ie" from that name). If you want to keep track of multiple connections, I suggest a list or dictionary. Jean-Paul -----La pièce jointe associée suit----- _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
dbcourriel-4all@yahoo.fr
-
exarkun@twistedmatrix.com