get the IP address of a host

Jorge Luiz Godoy Filho godoy at ieee.org
Fri Jan 7 07:53:29 EST 2005


Kartic, Quarta 05 Janeiro 2005 14:08, wrote:

> socket.gethostbyaddr(socket.gethostname())
> 
> will return a tuple containing fully qualified hostname,  alternative
> hostnames, ip addresses (>1 if multihomed).
>
> or
> 
> socket.gethostbyname(socket.gethostname())

None of these work with computers with more than one interface...  They get
only one of them.  It would be safer, then, to specify the desired
interface or use an alternative method.

-- 
Godoy.     <godoy at ieee.org>




More information about the Python-list mailing list