How to get IP address
ulope at gmx.de
Wed Mar 5 17:25:32 CET 2003
"Wayne Pierce" <wayne at mishre.com> schrieb im Newsbeitrag
news:2a897f11.0303040243.48067d01 at posting.google.com...
> Nagy László Zsolt <nagylzs at freemail.hu> wrote in message
news:<mailman.1046693203.18366.python-list at python.org>...
> > When you call gethostbyaddr('hostname1'), you will get addresses for
> > 'hostname1' only: ['192.168.1.1','192.168.1.2']
> Exactly, you are specifying that you only want to see the data for the
> specified hostname. If you do not put a specific hostname and use
> socket.gethostname() it should give you the info for everything.
> > You can't use gethostbyaddr() if you don't know IP address neither a DNS
> > name. ;-)
> Yes, you can. gethostbyaddr() can be pointed to the local system in a
> couple of different ways without an IP or DNS name, you could use
> 'localhost' and gethostname().
using localhost is propably not what he wants:
Python 2.1.3 (#1, Feb 24 2003, 20:48:47)
[GCC 2.95.3 20010315 (release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import socket
('localhost', , ['127.0.0.1'])
and yes this machine has (several) other Hostnames and ips
More information about the Python-list