How to determine whether client and server are on the same host

Michael Torrie torriem at gmail.com
Tue Nov 26 19:14:03 EST 2013


On 11/25/2013 12:35 PM, Malte Forkel wrote:
> I have a Python application that communicates with a server via telnet.
> Host and port of the server are supplied by the user when the
> application is started.
> 
> How can I determine from within the application whether the server's
> host actually is the local host? (In that case I could implement an
> operation not available in the telnet-based protocol by directly
> accessing the local filesystem.)
> 
> Sounds like there should be an obvious solution. Unfortunately, I
> haven't found it yet :-)

I believe socket.getsockname() can return the IP address of the
connecting client if you're using standard tcp/ip sockets.



More information about the Python-list mailing list