Windows getting local ip address

Arne Ludwig arne at citde.net
Thu Mar 23 07:48:28 EST 2006


That man is a genius:

>>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> s.connect(("gmail.com",80))
>>> print s.getsockname()
('192.168.0.174', 2768)
>>> s.close()

Should work on Windows as well.




More information about the Python-list mailing list