socket.gethostbyname returns `wrong` result?
Frank Miles
fpm at u.washington.edu
Mon Jul 26 18:29:43 EDT 2004
Hi everyone...
I'm trying to use the IP address as a way of detecting the current state
of my laptop. [Using laptop-net, it senses what network it's connected
to, and configures various parameters including IP address. This seems
to work properly, as reflected in the `ifconfig` output.]
Unfortunately while the simple script:
import socket
print socket.gethostbyname(socket.gethostname())
works on my desktop machines and server, on the laptop it gives:
127.0.0.1
which, of course, doesn't provide any idea as to the state of the network.
Is there any way to coerce the external IP#? Or another way of accessing
this number?
TIA for any tips or pointers to relevant docs!
-frank
--
More information about the Python-list
mailing list