obtain client ip address from SimpleXMLRPCServer ?

Peter Gsellmann peter-gsellmann at eunet.at
Fri Jan 27 19:14:58 EST 2006


stuff at mailzilla.net wrote:

> Thanks for the reply Peter.  Can you provide a code snippet for
> extracting this data.  When I print the dir() of the SimpleXMLRPCServer
> instance I do not see a request_handler attribute or method.
this is ok.
In the serverclass-object, there is no such method because the server
doesn't know which client would connect. It is a long-life object.

Each time a client connects the server creates another sort of object,
the so-called request-handler. This is a short-live object which terminates
when the request is answered. Only this object has knowledge of the client
as it holds the connection.

If you make a subclass of SimpleXMLRPCRequestHandler you can add or
override methods and add a line like this:
        print self.address_string()

A sample for such subclassing is given in the file SimpleXMLRPCServer.py
itself. (usually in /usr/lib/python/ )

Peter




More information about the Python-list mailing list