473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

obtain client ip address from SimpleXMLRPCServer ?

Is it possible to obtain the client's ip address from a
SimpleXMLRPCServer instance or subclass instance? When running
SimpleXMLRPCServer with logRequests = 1, the xmlrpc server prints out
the fqdn on the console, however, I'm not sure if this information
(either fqdn or ip address) is available to the SimpleXMLRPCServer
instance. Can somebody shed some light on how to obtain this
information?

Thanks,

Phil

Jan 23 '06 #1
4 4152
st***@mailzilla.net wrote:
Is it possible to obtain the client's ip address from a
SimpleXMLRPCServer instance or subclass instance? When running
SimpleXMLRPCServer with logRequests = 1, the xmlrpc server prints out
the fqdn on the console, however, I'm not sure if this information
(either fqdn or ip address) is available to the SimpleXMLRPCServer
instance. Can somebody shed some light on how to obtain this
information?

The request-handler has the method: address_string()

Peter
Jan 24 '06 #2
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.

Phil

Jan 27 '06 #3
st***@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

Jan 28 '06 #4
Thanks again Peter. I found 2 potential solutions for obtaining the ip
address of the incoming
connection. The first was to subclass SimpleXMLRPCRequestHandler class
and pass it
to the SimpleXMLRPCServer constructor. In doing so, I could directly
access the client_address via self.client_address. This worked just
fine but was a bit overkill.

The other solution I noticed was that SimpleXMLRPCServer's (which
ultimately subclasses BaseServer) handle_request method invokes
get_request (which merely calls self.socket.accept() -- which returns a
tuple including the ip address). By re-implementing get_request() as
such:

def get_request(self):
req = self.socket.accept()
ip_address = req[1][0]
return req

I can grab the ip address for internal use and have the get_request
method return the expected data for use by hande_request().

Now I just need to find a thread-safe way of passing this data back to
the XMLRPC server's registered_instance.

Jan 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Maxim Khesin | last post by:
Hi, the typical usage of SimpleXMLRPCServer registers some class with the server instance and then jumps into a serve-forever loop, e.g. server = SimpleXMLRPCServer(('', 8000))...
5
by: Jeronimo Bertran | last post by:
Hello, We have developed a socket tcpip server in .net that accepts calls from clients. Using the connected socket we are able to use the Socket.RemoteEndPoint to obtain the IP address of the...
0
by: Thomas G. Apostolou | last post by:
Hello all, I use Python 2.3.3 and try to patch SimpleXMLRPCServer.py with the patch i got from Python.org. so after changing to the directory where both SimpleXMLRPCServer.py and...
0
by: Eirikur Hallgrimsson | last post by:
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...
0
by: Jeremy Monnet | last post by:
Hello, I've started python a few weeks ago, and to now everything went fine with my cookbook and a learning book. Now, I've tried the SimpleXMLRPCServer, and it worked OK untill I tried to...
4
by: Stefka | last post by:
Hi all, I try to implement a python xml-rpc server and call it from a php client. If the server and the client are on the same machine (localhost) the communication between them is just fine....
1
by: tsjuan | last post by:
Hello python users, I am just learning on how to use xmlrpc and stumbled upon how to pass com object from server to client side. The client side complain about can't marshall the com object....
1
by: Jan Danielsson | last post by:
Hello all, I writing an application based on the SimpleXMLRPCServer class. I would like to know the IP address of the client performing the RPC. Is that possible, without having to abandon the...
3
by: OpenPavilion | last post by:
Hello community, maybe one of you can help me out with a question regarding the transfer of objects betwen client an server: I have three files: ####### ClassA.py ####### class ClassA: def...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.