Getting local IP address...

Mike Fletcher mfletch at tpresence.com
Tue Jul 18 19:12:46 EDT 2000


Mea Culpa.  "Never post code without explanation." (or something like that).
I'll start at the end of your points, "why would you want to know your IP
address?"
	The primary motivator for knowing your IP address today is likely
person-to-person services.  Currently becoming a buzzword, these services
include Napster, Gnutella, etc., as well as multi-user games, virtual
reality (what I'm doing) and the like. In these situations, user's machines
are configured to provide a limited service (such as file sharing or game
hosting) and their address is published through a centralized or distributed
listing service.  With systems that are UDP based (most game-level
multi-user technologies), there is seldom an available TCP connection within
the system, so the (naive) implementation just creates such a connection.

"Reliance on www.python.org"
	This was just stupidity on my part :) .  The default remote address
should have been something like ("www.yourcompanyservers.com", 80), that is,
the remote address should be a server which is part of your enterprise (the
use of Python.org was intended to imply, for Python users, a server within
our enterprise, (it was poorly communicated (strange note: when copying the
original post, I actually changed this address explicitly to make this point
(the original was "www.tpresence.com" , because I figured people might not
know where I work!)))) which is on the "public Internet".

"wasteful"
	Again, I assumed too much.  This _is_ wasteful code, and should be
treated as a base technique from which to build real code.  My own code
(written after the original posting (of about a month ago if I recall
correctly)) actually uses a cache, checking the IP address only once per
session with our company Web servers as the remote target.  As you mention,
it's a fairly light burden (3 small packets under ideal conditions), but
yes, it is conspicuous.

Glad I'm not on Linux, no sir, not after that lashing ;) .  I'm not one of
those darn insular Linux people.  I'll stick right here on Windows, where
every single developer is an absolute fanatic about making every piece of
code cross platform and portable.  No sir!  You'd never catch _us_ using
proprietary technologies.

Pay no attention to the COM behind the curtain...
Mike

-----Original Message-----
From: Donn Cave [mailto:donn at u.washington.edu]
Sent: Tuesday, July 18, 2000 1:13 PM
To: python-list at python.org
Subject: Re: Getting local IP address...


...
I'm not so crazy about this function either, despite that my name appears
in it!  But my problem is that it introduces an external and otherwise
irrelevant dependency on the DNS name www.python.org and its HTTP service.
When I did this in my own application (on BeOS, in MIT Kerberos 5, which
encodes the local IP in the ticket), I used my own primary DNS service
as the target.  This IP address is always known to the local system in
advance and really has to be in service or you're sunk anyway.

Will these connections every time an application wants to determine its
own IP bring the host to its knees?  Give me a break.  This, in a Python
newsgroup!  Compare to the network burden of resolving DNS names, etc.
Waste is bad, but this is a conspicuous but very small cost compared to
huge routine expenses that are buried under DNS lookups, NFS remote mounted
filesystems etc.
...
On the bright side, generally it's not necessary to know your own
IP address.  I'm curious why we are seeing this question so often,
what are folks doing out there?
...




More information about the Python-list mailing list