Getting local IP address...

Cameron Laird claird at starbase.neosoft.com
Tue Jul 18 10:15:23 EDT 2000


In article <3974183d_2 at my.newsfeeds.com>,
Stephen Hansen <stephen at cerebralmaelstrom.com> wrote:
>    Um, jeez. I'm rather surprised by these responses -- I assumed it
>was some simple little function somewhere I was missing.. I'm also
>even more surprised at the differences between the three approaches
>
>-- #1 -- socket.gethostbyname(socket.gethostname())
>-- #2 -- Some complicated stuff dealing with asking Linux (which,
>incidentely, is bad since i'm primarily on a Windows machine for
>the time being -- and in the future will be on a *BSD, and hope
>to have my program working on all three :)) what the address is
>on the given ethernet card..
>-- #3 -- Just go all out and connect, since in the process you
>have to be telilng the other side where you are, so you can
>get it that way.
>
>#2 and #3 just seem .. convoluted .. as heck. But because so
>many people sugguested them, I have to assume that they
>beileve there is some central problem with #1... What is it? :)
			.
			.
			.
Yes, there is a central problem that drives people
toward convolution in this area.  As the OSs are
defined in their full generality, there is no guar-
antee of a particular numeric address until the
connection is established.  I sympathize with the
perception of wastefulness.  That truly is how IP
works, though.

On the other hand, the most common configurations
allow for shortcuts that slash orders of magnitude
off that kind of processing.  If you know you con-
nect through Ethernet as one poster explained, it's
certainly OK by me to interrogate your NIC at a
hardware level.

I've been threatening to write a tutorial on this
subject ...
-- 

Cameron Laird <claird at NeoSoft.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



More information about the Python-list mailing list