How to get client's IP address in the threaded case of SimpleXMLRPCServer?

Chris Lambacher chris at kateandchris.net
Sun May 7 10:04:47 EDT 2006


On Fri, May 05, 2006 at 05:02:57PM -0400, Eirikur Hallgrimsson wrote:
> Okay, I've banged my head against this for about three days on and off.
> 
> The client's IP is passed to my handler in the non-threaded case.
> 
> It's not in the threaded case, which is actually rather different with a
> couple of mixin classes mixing things up.  I'm not confused, it's not
> passed.
> 
> I can't figure out how to get the client IP address at all from inside
> my program.  I can reach the socket object via my server object, but the
> connection has been dropped before my handler is called.
> 
> Any help or pointers would be appreciated.  At this point I think I
> would need to make changes in SimpleXMLRPCServer, or write a
> replacement, which doesn't appeal to me.
Your handler object should be getting set up with the client_address property.
If not you need to show us some small subset of your app that demonstrates the
issue.

You can also inherit from SimpleXMLRPCServer and override verify_request, from
BaseServer, if you want the option of blocking requests based on source
address.

-Chris



More information about the Python-list mailing list