SimpleXMLRPCServer and socket

Juju jujucece at gmail.com
Mon Sep 25 20:20:38 CEST 2006


Hi,

First, sorry for my poor English !

I used the SimpleXMLRPCServer facility of Python to develop a
multithread-server, here's  part of my code :
--
class TotoSimpleXMLRPCServer(SocketServer.ThreadingMixIn,
SimpleXMLRPCServer.SimpleXMLRPCServer):

  def __init__(self, addr):
    SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, addr,
SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, 0)

  def _dispatch(self, method, params):
    if method == "toto58":
      ...
--

The problem I have, is I don't know how to get the port used by the
remote host ?

I tried to get this information with the socket object of the Server,
but this socket always correspond to the LISTENING socket and not the
ESTABLISHED one ! (With the lsof command, I see 2 connexions 1 LISTEN
and 1 ESTABLISHED).

So, when I tried to getpeername() on this object, I've an Exception
(107, 'Transport endpoint is not connected'), which is normal for a
listening connexion.

How can I get the socket object corresponding to the ESTABLISHED
connexion ? (Or how can I do to get the port of the remote host ?)

Thanks in advance...
Juju



More information about the Python-list mailing list