[Twisted-Python] Get IP of connecting client in XMLRPC server

Remy C. Cool dev-python at smartology.nl
Fri Jun 11 09:34:56 EDT 2004


On 18 May 2004, the following message was posted to this mailinglist:

Jp Calderone exarkun at divmod.com wrote:

>Daniel Newton wrote:
> I have a simple XML-PRC server similar to the example below:
> from twisted.web import xmlrpc, server
> class Example(xmlrpc.XMLRPC):
>     """An example object to be published."""
>     def xmlrpc_add(self, a, b):
>         """Return sum of arguments."""
>         return a + b

       def xmlrpc_whatIsMyAddress(self):
           return self.transport.getPeer().host

> if __name__ == '__main__':
>     from twisted.internet import reactor
>     r = Example()
>     reactor.listenTCP(7080, server.Site(r))
>     reactor.run()
> I want to be able to get the address of the client that calls the 
> method can anyone help me with this?

This solution didn't work because 'transport' isn't a property of the 
Example class.

I'm currently in the process of changing from a customized 
SimpleXMLRPCServer to a twisted XMLRPC server solution and I need to 
insert the client IP into the attributes passed to the called xmlrpc 
method. Anyone who knows the answer and is willing to share the info?


More information about the Twisted-Python mailing list