[IronPython] socket.getfqdn problem on 2.6.1 RC1.

Lepisto, Stephen P stephen.p.lepisto at intel.com
Wed Apr 7 16:36:10 CEST 2010


In IronPython, using socket.getfqdn('127.0.0.1') returns the local host name.  Under CPython, this always returns 'localhost'.

The CPython documentation for getfqdn() does explicitly state "If name is omitted or empty, it is interpreted as the local host."

Therefore, if you change your call to leave out the '0.0.0.0', then the code will behave the same on both CPython and IronPython.

IronPython:
>>> import socket
>>> socket.getfqdn()
mydomain.name.here

CPython:
>>> import socket
>>> socket.getfqdn()
mydomain.name.here


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Carlos Alberto Costa Beppler
Sent: Wednesday, April 07, 2010 7:26 AM
To: Discussion of IronPython
Subject: [IronPython] socket.getfqdn problem on 2.6.1 RC1.

Hi, I´m trying to use the HTTPServer class from de BaseHTTPServer.py
on standard library on IronPython 2.6.1 RC1.

But the server stops with an socket exception on startup as shown bellow.

C:\Program Files\Tools>ipy
IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.3607
Type "help", "copyright", "credits" or "license" for more information.
>>> import BaseHTTPServer
>>> BaseHTTPServer.test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\IronPython\Lib\BaseHTTPServer.py", line 584, in test
  File "C:\Program Files\IronPython\Lib\SocketServer.py", line 400, in __init__
  File "C:\Program Files\IronPython\Lib\BaseHTTPServer.py", line 110, in server_
bind
ValueError: IPv4 address 0.0.0.0 and IPv6 address ::0 are unspecified addresses
that cannot be used as a target address.
Parameter name: hostNameOrAddress

This is because the method getfqdn of the socket class is blowing up
when the string '0.0.0.0' is passed to it. For example:

C:\Program Files\Tools>ipy
IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.3607
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getfqdn('0.0.0.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: IPv4 address 0.0.0.0 and IPv6 address ::0 are unspecified addresses
that cannot be used as a target address.
Parameter name: hostNameOrAddress

On CPython the same call returns the current host name, like bellow.

C:\Users\beppler>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getfqdn('0.0.0.0')
'Beppler.mps.interno'
>>>


Is it possible to fix this for the 2.6.1 release?
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the Ironpython-users mailing list