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

Chris Angelico rosuav at gmail.com
Tue Nov 26 06:38:37 EST 2013


On Tue, Nov 26, 2013 at 10:26 PM, Malte Forkel <malte.forkel at berlin.de> wrote:
> Most of the application's functionality uses the telnet connection to
> communicate with the server. One special operation is not available in
> the protocol, but can be implemented by a direct file-based operation if
> the application is run on the server itself. I would like to use that
> option if technically feasible.

There is another way you might be able to do this. The server could
simply create a cookie in the file system - say, a file in /tmp with a
randomly-generated name - and it can announce that to the client. If
the client sees the same file in what it sees as /tmp, then it can
assume that it's running on the server. Obviously there's a miniscule
probability of an accidental collision, and someone could deliberately
fool it, but for a simple check, that might work.

ChrisA



More information about the Python-list mailing list