In article <[EMAIL PROTECTED]>, Simon Brunning <[EMAIL PROTECTED]> wrote:
> On 15 Apr 2005 06:03:06 -0700, codecraig <[EMAIL PROTECTED]> wrote: > > hi, > > how can i use python to figure the ip address of the machine which > > the python script is running on? I dont mean like 127.0.0.1....but i > > want the external IP address (such as ipconfig on windows displays). > > On Windows, this works: > > socket.gethostbyname(socket.gethostname()) > > Is that OK on real operating systems too? It will work sometimes, but there is nothing I know of that specifically distinguishes "the" external network. If you want something that reliably finds a network that will be used for a certain type of connection, then the best thing to do is make a connection like that, and inspect the results. The getsockname() method shows the IP address. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list