Python 2.3: socket.gethostbyname(socket.gethostname()) fails?

E

Eric Brunel

Hi all,

I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I
have one problem that I can't figure out: when I wanted to get "the" IP address
of the current host with Python 2.1, I did:

Python 2.1.1 (#12, Apr 10 2002, 17:52:08)
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2
Type "copyright", "credits" or "license" for more information.'192.168.1.1'

I know it just returns one of the IP addresses of the current host, but it was
OK for what I did with it. Doing the same thing with Python 2.3, I get:

Python 2.3.2 (#1, Oct 27 2003, 15:34:53)
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
socket.gaierror: (-2, 'Name or service not known')

Is it a bug? I saw I can get the same information via getaddrinfo, then
getnameinfo, but why doesn't gethostbyname work in this case?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top