[IronPython] socket.getfqdn problem on 2.6.1 RC1.

Carlos Alberto Costa Beppler beppler at gmail.com
Wed Apr 7 16:39:22 CEST 2010


The problem is that the HTTPServer from standard lib is doing the call
on line 109-110 of the file BaseHTTPServer.py on method server_bind.
See the code bellow.

class HTTPServer(SocketServer.TCPServer):

    allow_reuse_address = 1    # Seems to make sense in testing environment

    def server_bind(self):
        """Override server_bind to store the server name."""
        SocketServer.TCPServer.server_bind(self)
        host, port = self.socket.getsockname()[:2]
        self.server_name = socket.getfqdn(host)
        self.server_port = port

The host variable gets '0.0.0.0' and when the call to socket.getfqdn
is made the exception is thrown.




On Wed, Apr 7, 2010 at 11:36, Lepisto, Stephen P
<stephen.p.lepisto at intel.com> wrote:
> 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
> _______________________________________________
> 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