[Pythonmac-SIG] Subtle difference between PythonMac and command line on OS X

Pieter Claerhout pieter.claerhout@pandora.be
Sat, 6 Apr 2002 00:08:21 +0200


I'm afraid I was mixing up some stuff. I took a closer look at the code, and
the socket part does work fine, it's just the xmlrpcServer.py module I'm
using
that is having troubles with this. Sorry for the confusion!

Apart from that, in my example, the 192.168.0.4 is indeed the primary
interface but doesn't have a hostname (seems to be the default if you
install Mac OS X). So this means that if you use the command line Python
version, you'll have a hard time finding out the IP address of the primary
interface, while MacPython gives it by default.

I have it working now, so I'm a happy man again :-)

Cheers,


--Pieter


-----Original Message-----
From: pythonmac-sig-admin@python.org
[mailto:pythonmac-sig-admin@python.org]On Behalf Of Jack Jansen
Sent: Saturday, April 06, 2002 12:00 AM
To: pieter.claerhout@pandora.be
Cc: 'Tony Lownds'; pythonmac-sig@python.org
Subject: Re: [Pythonmac-SIG] Subtle difference between PythonMac and
command line on OS X



On vrijdag, april 5, 2002, at 10:01 , Pieter Claerhout wrote:

> That did work under command line Python, but not using Python
> for Mac.

This is the real bug, then, but see below.

Apparently there is no hostname for your 192.168.0.4 address
(which, I assume, is your primary interface) and then the C
implementations of gethostname() diverge: the unix version looks
for a hostname for the next interface (the loopback interface)
and the GUSI version gives up (which leads socket.gethostname()
to return the numeric address).

But: binding to '' should always work, and should always bind to
any interface (i.e. incoming connections on any interface will
connect to your socket).

And I can't reproduce your behaviour (MacPython 2.2c2). I've
done the following
 >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 >>> s.bind(('', 4242))  # or 4343 for MacPython
 >>> s.listen(1)
and here's the relevant bit of my "netstat -an" output:
tcp        0      0
*.4343                 *.*                    LISTEN
tcp        0      0
*.4242                 *.*                    LISTEN

And my socket.gethostname() behaves the same as yours (my
primary interface also doesn't have a name associated with it).
--
- Jack Jansen        <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution --
Emma Goldman -



_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig