[Vm-dev] Re: [Pharo-dev] strange difference between localhost and
127.0.0.1 with a Zinc server on mac
Eliot Miranda
eliot.miranda at gmail.com
Sat Jun 14 14:17:48 UTC 2014
Hi Sven,
On Sat, Jun 14, 2014 at 4:09 AM, Sven Van Caekenberghe <sven at stfx.eu> wrote:
>
> On 14 Jun 2014, at 12:18, Ben Coman <btc at openInWorld.com> wrote:
>
> > Sven Van Caekenberghe wrote:
> >> In any case, the server socket used is normally listening on all
> interfaces [0.0.0.0]
> >>
> >> Sven
> >>
> >>
> >
> > Maybe it matters that [0.0.0.0] is the IPv4-Unspecified-Address
> > and it might make a difference to use IPv6-Unspecified-Address
> [0:0:0:0:0:0:0:0] or [::]
> >
> > cheers -ben
>
> I guess it all depends on the Socket plugin. ZnServer has #bindingAddress:
> which eventually calls Socket>>#listenOn:backlogSize:interface: but the
> question is, what is acceptable as last argument. And how is the difference
> between v4 and v6 handled. There is a 'primitives-ipv6' category, but no
> #listenOn with an interface there.
>
I wonder whether this commit is relevant:
r2552 | eliot | 2012-05-02 16:13:02 -0700 (Wed, 02 May 2012) | 19 lines
CogVM source as per VMMakerr.oscog-eem.159
...
Fix limitation in platforms/unix/plugins/SocketPlugin/sqUnixSocket.c which
could
cause NetNameResolver localHostAddress to answer 0 (if host has a set
hostname
not being honoured by local DNS servers). Fix falls back to localhost.
...
Here's the relevant part of the
platforms/unix/plugins/SocketPlugin/sqUnixSocket.c change:
-sqInt sqResolverLocalAddress(void) { return
nameToAddr(localHostName); }
+sqInt sqResolverLocalAddress(void)
+{ sqInt localaddr = nameToAddr(localHostName);
+ if (!localaddr)
+ localaddr = nameToAddr("localhost");
+ return localaddr;
+}
This fixed several socket tests on my Mac OS box. I think it affects
systems behind a broadband router, at least that's how it asffected me on
my laptop at home. And here's what is probably the root cause in
platforms/unix/plugins/SocketPlugin/sqUnixSocket.c:
...
static char localHostName[MAXHOSTNAMELEN];
static u_long localHostAddress; /* GROSS IPv4 ASSUMPTION! */
...
/* start a new network session */
sqInt sqNetworkInit(sqInt resolverSemaIndex)
{
if (0 != thisNetSession)
return 0; /* already initialised */
gethostname(localHostName, MAXHOSTNAMELEN);
localHostAddress= nameToAddr(localHostName);
thisNetSession= clock() + time(0);
if (0 == thisNetSession)
thisNetSession= 1; /* 0 => uninitialised */
resolverSema= resolverSemaIndex;
return 0;
}
...
and so if gethostname answers something weird, attempts to access localHost
are screwed from initialization on.
HTH
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20140614/d0da3f0a/attachment.htm
More information about the Vm-dev
mailing list