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

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'say,': 0.05; 'subject:same': 0.07; 'get.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tcp/ip': 0.09; 'type;': 0.09; 'url:localhost': 0.09; 'subject:How': 0.10; 'python': 0.11; 'wrote': 0.14; 'finney': 0.16; 'invoking': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'second-guess': 0.16; 'supplied': 0.16; 'unix,': 0.16; 'written': 0.21; '(in': 0.22; 'header:User-Agent:1': 0.23; "shouldn't": 0.24; 'header:X-Complaints-To:1': 0.27; 'appear': 0.29; 'host': 0.29; 'unix': 0.29; 'network.': 0.30; 'asked': 0.31; 'url:wiki': 0.31; 'facility': 0.31; 'url:wikipedia': 0.31; 'wright': 0.31; 'writes:': 0.31; 'allows': 0.31; 'subject:the': 0.34; 'could': 0.34; "can't": 0.35; 'connection': 0.35; 'but': 0.35; 'accessing': 0.36; "i'll": 0.36; 'url:org': 0.36; 'should': 0.36; 'application': 0.37; 'implement': 0.38; 'server': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'read': 0.60; 'is.': 0.60; 'radio': 0.60; 'skip:\xe2 10': 0.65; 'within': 0.65; 'determine': 0.67; 'started.': 0.68; 'listening': 0.74; 'music': 0.75; '8bit%:46': 0.78; 'connection,': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: How to determine whether client and server are on the same host
Date Tue, 26 Nov 2013 10:41:44 +1100
References <l708pt$r5b$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host rasputin.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:xspvZe/OY2YMV5oPSQivZPmuFzY=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3205.1385422916.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385422916 news.xs4all.nl 15939 [2001:888:2000:d::a6]:49787
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60469

Show key headers only | 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