[Twisted-Python] pb server how to get client IP address

Martin Stenhård stenis at stenhard.net
Sat Feb 14 17:05:10 EST 2004


> -----Original Message-----
> From: Brian Warner [mailto:warner at lothar.com]
> I poked around a bit and haven't found any way to get at it. If the client
> has given you access to one if its own objects (perhaps as the 'mind'
> reference in the realm.requestAvatar() call), then you can use it to get
> the
> Broker:
> 
>  mind.broker.transport.getPeer()
> 

Thanks Brian

mind.broker.transport.getPeer() did job I use mind and I get the client IP
successfully now.

class MyPerspective(pb.Avatar):
    connections = 0
    def __init__(self, name):
        self.name = name    
        self.position = [0.0,0.0,0.0]
        self.rotation = [0.0,0.0,0.0]  
        self.rotation2 = [0.0,0.0,0.0]  
        self.velocity = [0.0,0.0,0.0] 
        self.state = 0 
 
    def attached(self, mind):
        ip = mind.broker.transport.getPeer()
	  print ip


Thanks
/Martin
http://stenhard.net






More information about the Twisted-Python mailing list