On Sun, Dec 5, 2010 at 4:07 PM, Umut Aydin <devnetw...@gmail.com> wrote:
> Hello everybody. Hope you have a good weekend. > > I'm trying to port my distributed job server project to twisted but I > have a few questions. > > I just tested twisted with protocol.Protocol socket handler class and > it seems like that it creates a new instance for each connection. I > want to put those connection's ip addresses into an array. Where > should I do that exactly? > > How can I get ip address and port information out of > self.transport.getPeer()? > Each created protocol comes with a refrence to factory that is creating them, which is a right place of doing all the inter protocol operations . You can access it via factory attribute of protocol. So, in a typical twisted program you can refer to the factory by doing self.factory in the created protocol. You can define an array called peers in factory and access it like self.factory.peers. Check out buildProtocol() method of twisted factories to customize protcol instantiation. Yes, transport.getPeers() gives you the remote end host and port. -- Thanks & Regards, Godson Gera Twisted Python India <http://blog.godson.in>
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python