[Vm-dev] unix nameToAddr() function appears to not work on Raspbian?

Bert Freudenberg bert at freudenbergs.de
Mon Sep 21 12:27:41 UTC 2015


On 21.09.2015, at 06:59, tim Rowledge <tim at rowledge.org> wrote:
> 
> On 20-09-2015, at 6:07 PM, David T. Lewis <lewis at mail.msen.com> wrote:
>> 
>> Um ... are you sure that this "worked" previously? I just tried a Squeak
>> 3.8 image, and it says that NetNameResolver localHostAddress is 127.0.1.1,
>> which is exactly what Squeak 5.0 says on this same computer.
>> 
>> I suspect that you are just running Squeak on a different platform, and
>> "NetNameResolver addressForName: self localHostName" is in fact different
>> compared to whatever it was on your previous systems.
> 
> We can be sure it used to work since the Scratch hosting for the mesh network relies upon it (since about 1935) and a large number of thousands of people have been (and still need to be) using it in classrooms around the world. That’s why I’m more than a bit puzzled and concerned. As the article John pointed to implies it’s entirely likely that it’s nothing at all to do with ‘us’ but unfortunately we get to have to solve it. Seems typical that it might be a fudge caused by gnome.

I’m pretty sure it never worked reliably, not on the gazillions of Linux machines anyway. I remember discussions about this from at least 10 years ago (when OLPC got started).

It’s well-known that gethostbyname(gethostname()) won’t reliably work (e.g. http://tinyurl.com/d6e7gjl).

There’s two more reliable solutions. Either enumerate all network interfaces and guess the correct one. Or open a connection to somewhere on the internet and look at the local socket’s address (which the OS assigned to the right interface using its routing tables). The latter one is supposed to work pretty much across platforms. Here’s how it works in Python:

python -c "import socket; s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.connect(('8.8.8.8', 80)); print(s.getsockname()[0]); s.close()"

I tried that on a Linux and OS X, works on both. We should be able to do that in Squeak using a UDP socket, no?

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4115 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150921/a93201c8/smime-0001.bin


More information about the Vm-dev mailing list