[Twisted-Python] two twisted clients, how can I trigger the other one's callback in one's callback?
arnarbi at gmail.com
Wed Jun 20 07:52:06 EDT 2007
On 6/20/07, slowtech chen <slowtech.chen at yahoo.com> wrote:
> I have 2 clients, one gets a message from a server, once I get
> the message, I want to send it with the other client to another
> server. how can i do this? can I add some customized events
> and notice the other client? Thanks.
Are they both running in the same process?
This is my first non-question post on this list, so please forgive me
if I'm giving bad advice - hopefully someone will correct me if I am.
If they're both in the same process you can just make calls between
from twisted.internet.protocol import Protocol
from twisted.internet import reactor, protocol
def connectionLost(self, reason):
def dataReceived(self, data):
# repeat the data to all other connections
print "relaying data"
for conn in self.factory.connections:
if conn != self:
protocol = YourProtocol
self.connections = 
if __name__ == '__main__':
f = YourClientFactory()
reactor.connectTCP("hostname1", 10001, f)
reactor.connectTCP("hostname2", 10002, f)
More information about the Twisted-Python