Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60469

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

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: How to determine whether client and server are on the same host
Date 2013-11-26 10:41 +1100
References <l708pt$r5b$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.3205.1385422916.18130.python-list@python.org> (permalink)

Show all headers | View raw


Malte Forkel <malte.forkel@berlin.de> writes:

> 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.)

On Unix, this is up to the person invoking the program: the “sockets
facility allows for a host-local connection to appear as though it's
going over a network.

    <URL:https://en.wikipedia.org/wiki/Localhost>
    <URL:https://en.wikipedia.org/wiki/Unix_domain_socket>

In other words: Your program shouldn't go snooping around to
second-guess the connection type; if the user asked for a TCP/IP
connection, that's what they should get. If they want to take advantage
of a local connection, they can use a Unix domain socket.

-- 
 \     “I wrote a song, but I can't read music so I don't know what it |
  `\    is. Every once in a while I'll be listening to the radio and I |
_o__)        say, ‘I think I might have written that.’” —Steven Wright |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to determine whether client and server are on the same host Ben Finney <ben+python@benfinney.id.au> - 2013-11-26 10:41 +1100

csiph-web