473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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.
import socket
socket.gethostbyname(socket.gethostname()) '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. import socket
socket.gethostbyname(socket.gethostname())

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?
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #1
0 5986

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jstobbs | last post by:
Hi all I am trying to create a lighweight tcp proxy server. I got this code from ActivePython documentation. What I am trying to accomplish, is I need to connect to local instance of the...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
0
by: dan.jakubiec | last post by:
I'm trying to write a Python app which accepts a socket connection and then spawns another Python process to handle it. I need it to run under both Linux and Windows. I have it working under...
5
by: msj | last post by:
Seems like sockets are about 6 times faster on OpenSUSE than on Windows XP in Python. http://pyfanatic.blogspot.com/2007/02/socket-performance.html Is this related to Python or the OS? ...
6
by: =?utf-8?q?O=C4=9Fuz_Yar=C4=B1mtepe?= | last post by:
Is it possible to send a data object like a tuple or a list in socket programming? If so how? It seems with socket module it is only possible to send strings. -- Oğuz Yarımtepe...
1
by: inhahe | last post by:
i'm trying to make a .dll that will let me use WSAPoll, which is a windows sockets function, to mimic select.poll on a windows box. i cbb learning python extensions, so i'm just going to use...
2
by: srinivasan srinivas | last post by:
Hi, I am going to do some socket related programming in Python. Before that, I wish to know the Gotchas of Python Scoket Programming. Can anyone send me any link that satisfies my needs?? Thanks,...
1
by: =?iso-8859-1?q?C=E9dric_Lucantis?= | last post by:
Hi, Le Friday 13 June 2008 18:29:06 srinivasan srinivas, vous avez écrit : Yes, the friendly manual :) http://docs.python.org/lib/module-socket.html and if you want to know more about...
3
by: Helmut Jarausch | last post by:
Hi, trying to build Python-3.0b1 on my Gentoo Linux box fails with Failed to find the necessary bits to build these modules: _gestalt Looking at setup.py it seems that module '_gestalt' is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.