localHostAddress

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

localHostAddress

Bob Arning
I haven't tried this in a while (previous computer), but I'm not able to get the address of my computer.

NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)

All the other NetNameResolver functions seem to be working fine, including giving it my address and having it lookup the name.

This is MacOS 10.4 and I have tried in a Croquet 1.0 image and a much older image as well.

I have a feeling this requires some sort of UNIX incantation, but I'm not sure what. Any ideas?

Cheers,
Bob
Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Brad Fuller-2
It works on XP in the latest squeak-dev 3.10

Robert Arning wrote:

> I haven't tried this in a while (previous computer), but I'm not able to get
> the address of my computer.
>
> NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)
>
> All the other NetNameResolver functions seem to be working fine, including
> giving it my address and having it lookup the name.
>
> This is MacOS 10.4 and I have tried in a Croquet 1.0 image and a much older
> image as well.
>
> I have a feeling this requires some sort of UNIX incantation, but I'm not
> sure what. Any ideas?
>
> Cheers,
> Bob
>  


Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

johnmci
In reply to this post by Bob Arning
Let's see. First on os-x we just use the unix socket code so looking  
at the primitive we see

EXPORT(sqInt) primitiveResolverLocalAddress(void) {
        sqInt addr;
        sqInt _return_value;

        addr = sqResolverLocalAddress();

which is

sqInt sqResolverLocalAddress(void) { return nameToAddr
(localHostName); }

which is

/* answer the IP address for the given hostname */

static int nameToAddr(char *hostName)
{
   struct hostent *he;

   lastError= 0; /* ditto */
   if ((he= gethostbyname(hostName)))
     return ntohl(*(long *)(he->h_addr_list[0]));
   lastError= h_errno; /* and one more ditto */
   return 0;
}

      The gethostbyname(), gethostbyname2() and gethostbyaddr()  
functions each
      return a pointer to an object with the following structure  
describing an
      internet host referenced by name or by address, respectively.  
This
      structure contains either the information obtained from the  
name server,
      named(8), or broken-out fields from a line in /etc/hosts.  If  
the local
      name server is not running these routines do a lookup in /etc/
hosts.

      struct  hostent {
              char    *h_name;        /* official name of host */
              char    **h_aliases;    /* alias list */
              int     h_addrtype;     /* host address type */
              int     h_length;       /* length of address */
              char    **h_addr_list;  /* list of addresses from name  
server */
      };


Now on this machine there are multiple network interfaces

en0 is ethernetport
en1 is 802.11n (wireless, active)
en2 is Parallels virtual interface for Host-Guest
en3 is Parallels virtual interface for NAT

I'll note the machine is otter.local.
If I ping say otter.local it says

[otter:~] johnmci% ping Otter.local
PING otter.local (10.37.129.2): 56 data bytes
64 bytes from 10.37.129.2: icmp_seq=0 ttl=64 time=0.034 ms
64 bytes from 10.37.129.2: icmp_seq=1 ttl=64 time=0.070 ms
64 bytes from 10.37.129.2: icmp_seq=2 ttl=64 time=0.064 ms
64 bytes from 10.37.129.2: icmp_seq=3 ttl=64 time=0.090 ms

another try gave me

[otter:~] johnmci% ping otter.local
PING otter.local (192.168.1.130): 56 data bytes
64 bytes from 192.168.1.130: icmp_seq=0 ttl=64 time=0.024 ms
64 bytes from 192.168.1.130: icmp_seq=1 ttl=64 time=0.066 ms
64 bytes from 192.168.1.130: icmp_seq=2 ttl=64 time=0.080 ms
64 bytes from 192.168.1.130: icmp_seq=3 ttl=64 time=0.086 ms

In checking the results from gethostbyname I get
h_name -> otter.local
h_aliases -> address -> 0x00000000
h_addresstype -> 2
h_length -> 4
h_addr_list -> address -> ox0a258102


So the gethostbyname is returning the address of the Parallels  
virtual interface for Hosts-Guest
So obviously the unix call might not return what you think it should  
if there are multiple interfaces active for your machine.
I'l do a ifconfig -a and see what's lurking

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         ether 00:17:f2:d9:57:35
         media: autoselect status: inactive
         supported media: autoselect 10baseT/UTP <half-duplex>  
10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback>  
10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex>  
100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX  
<full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-
duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         inet6 fe80::21b:63ff:fe02:d2db%en1 prefixlen 64 scopeid 0x5
         inet 192.168.1.130 netmask 0xffffff00 broadcast 192.168.1.255
         ether 00:1b:63:02:d2:db
         media: autoselect status: active
         supported media: autoselect
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST>  
mtu 1500
         inet6 fe80::201:23ff:fe45:6789%en2 prefixlen 64 scopeid 0x8
         inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
         ether 00:01:23:45:67:89
         media: autoselect status: active
         supported media: autoselect
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST>  
mtu 1500
         inet6 fe80::210:32ff:fe54:7698%en3 prefixlen 64 scopeid 0x9
         inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255
         ether 00:10:32:54:76:98
         media: autoselect status: active
         supported media: autoselect



On Oct 6, 2007, at 3:18 PM, Robert Arning wrote:

>
> I haven't tried this in a while (previous computer), but I'm not  
> able to get
> the address of my computer.
>
> NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)
>
> All the other NetNameResolver functions seem to be working fine,  
> including
> giving it my address and having it lookup the name.
>
> This is MacOS 10.4 and I have tried in a Croquet 1.0 image and a  
> much older
> image as well.
>
> I have a feeling this requires some sort of UNIX incantation, but  
> I'm not
> sure what. Any ideas?
>
> Cheers,
> Bob
> --
> View this message in context: http://www.nabble.com/ 
> localHostAddress-tf4581383.html#a13078111
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>

--
========================================================================
===
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===



Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Bob Arning
Thanks John,

I thought it was some of that UNIX stuff. Now if I could just understand it. :-) I've listed my ifconfig -a below if that helps narrow it down. The only other network interface seems to be Airport which is turned off. Any suggestions? Or is it just broken?

Cheers,
Bob

arning-dsl-209:~ bob$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::216:cbff:fe8e:b7d%en0 prefixlen 64 scopeid 0x4
        inet 209.143.91.34 netmask 0xfffffff8 broadcast 209.143.91.39
        ether 00:16:cb:8e:0b:7d
        media: autoselect (10baseT/UTP <half-duplex>) status: active
        supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 00:16:cb:b3:01:ad
        media: autoselect (<unknown type>) status: inactive
        supported media: autoselect
wlt1: flags=41<UP,RUNNING> mtu 1500
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 2030
        lladdr 00:16:cb:ff:fe:e7:ff:3a
        media: autoselect <full-duplex> status: inactive
        supported media: autoselect <full-duplex>
Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Jason Johnson-5
In reply to this post by johnmci
I would have to see your /etc/hosts.conf but you are pinging
"Otter.local" which does look like an external (i.e. not localhost)
address.  If you have more then one entry for Otter that points to
different interfaces then this could happen.

But if you ping "localhost" it should be 127.0.0.1 every time.  Also
note that regardless of what ping etc. may be reporting, all traffic
from Otter that actually goes to Otter is going over the loopback
interface, not either of those IP addresses.

On 10/7/07, John M McIntosh <[hidden email]> wrote:

> Let's see. First on os-x we just use the unix socket code so looking
> at the primitive we see
>
> EXPORT(sqInt) primitiveResolverLocalAddress(void) {
>         sqInt addr;
>         sqInt _return_value;
>
>         addr = sqResolverLocalAddress();
>
> which is
>
> sqInt sqResolverLocalAddress(void)              { return nameToAddr
> (localHostName); }
>
> which is
>
> /* answer the IP address for the given hostname */
>
> static int nameToAddr(char *hostName)
> {
>    struct hostent *he;
>
>    lastError= 0;                        /* ditto */
>    if ((he= gethostbyname(hostName)))
>      return ntohl(*(long *)(he->h_addr_list[0]));
>    lastError= h_errno;          /* and one more ditto */
>    return 0;
> }
>
>       The gethostbyname(), gethostbyname2() and gethostbyaddr()
> functions each
>       return a pointer to an object with the following structure
> describing an
>       internet host referenced by name or by address, respectively.
> This
>       structure contains either the information obtained from the
> name server,
>       named(8), or broken-out fields from a line in /etc/hosts.  If
> the local
>       name server is not running these routines do a lookup in /etc/
> hosts.
>
>       struct  hostent {
>               char    *h_name;        /* official name of host */
>               char    **h_aliases;    /* alias list */
>               int     h_addrtype;     /* host address type */
>               int     h_length;       /* length of address */
>               char    **h_addr_list;  /* list of addresses from name
> server */
>       };
>
>
> Now on this machine there are multiple network interfaces
>
> en0 is ethernetport
> en1 is 802.11n (wireless, active)
> en2 is Parallels virtual interface for Host-Guest
> en3 is Parallels virtual interface for NAT
>
> I'll note the machine is otter.local.
> If I ping say otter.local it says
>
> [otter:~] johnmci% ping Otter.local
> PING otter.local (10.37.129.2): 56 data bytes
> 64 bytes from 10.37.129.2: icmp_seq=0 ttl=64 time=0.034 ms
> 64 bytes from 10.37.129.2: icmp_seq=1 ttl=64 time=0.070 ms
> 64 bytes from 10.37.129.2: icmp_seq=2 ttl=64 time=0.064 ms
> 64 bytes from 10.37.129.2: icmp_seq=3 ttl=64 time=0.090 ms
>
> another try gave me
>
> [otter:~] johnmci% ping otter.local
> PING otter.local (192.168.1.130): 56 data bytes
> 64 bytes from 192.168.1.130: icmp_seq=0 ttl=64 time=0.024 ms
> 64 bytes from 192.168.1.130: icmp_seq=1 ttl=64 time=0.066 ms
> 64 bytes from 192.168.1.130: icmp_seq=2 ttl=64 time=0.080 ms
> 64 bytes from 192.168.1.130: icmp_seq=3 ttl=64 time=0.086 ms
>
> In checking the results from gethostbyname I get
> h_name -> otter.local
> h_aliases -> address -> 0x00000000
> h_addresstype -> 2
> h_length -> 4
> h_addr_list -> address -> ox0a258102
>
>
> So the gethostbyname is returning the address of the Parallels
> virtual interface for Hosts-Guest
> So obviously the unix call might not return what you think it should
> if there are multiple interfaces active for your machine.
> I'l do a ifconfig -a and see what's lurking
>
> en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>          ether 00:17:f2:d9:57:35
>          media: autoselect status: inactive
>          supported media: autoselect 10baseT/UTP <half-duplex>
> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback>
> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex>
> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX
> <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-
> duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none
> en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>          inet6 fe80::21b:63ff:fe02:d2db%en1 prefixlen 64 scopeid 0x5
>          inet 192.168.1.130 netmask 0xffffff00 broadcast 192.168.1.255
>          ether 00:1b:63:02:d2:db
>          media: autoselect status: active
>          supported media: autoselect
> en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST>
> mtu 1500
>          inet6 fe80::201:23ff:fe45:6789%en2 prefixlen 64 scopeid 0x8
>          inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
>          ether 00:01:23:45:67:89
>          media: autoselect status: active
>          supported media: autoselect
> en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST>
> mtu 1500
>          inet6 fe80::210:32ff:fe54:7698%en3 prefixlen 64 scopeid 0x9
>          inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255
>          ether 00:10:32:54:76:98
>          media: autoselect status: active
>          supported media: autoselect
>
>
>
> On Oct 6, 2007, at 3:18 PM, Robert Arning wrote:
>
> >
> > I haven't tried this in a while (previous computer), but I'm not
> > able to get
> > the address of my computer.
> >
> > NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)
> >
> > All the other NetNameResolver functions seem to be working fine,
> > including
> > giving it my address and having it lookup the name.
> >
> > This is MacOS 10.4 and I have tried in a Croquet 1.0 image and a
> > much older
> > image as well.
> >
> > I have a feeling this requires some sort of UNIX incantation, but
> > I'm not
> > sure what. Any ideas?
> >
> > Cheers,
> > Bob
> > --
> > View this message in context: http://www.nabble.com/
> > localHostAddress-tf4581383.html#a13078111
> > Sent from the Squeak - Dev mailing list archive at Nabble.com.
> >
> >
>
> --
> ========================================================================
> ===
> John M. McIntosh <[hidden email]>
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ========================================================================
> ===
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Edgar J. De Cleene
In reply to this post by Bob Arning



El 10/6/07 7:18 PM, "Robert Arning" <[hidden email]> escribió:

> I haven't tried this in a while (previous computer), but I'm not able to get
> the address of my computer.
>
> NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)
>
> All the other NetNameResolver functions seem to be working fine, including
> giving it my address and having it lookup the name.
>
> This is MacOS 10.4 and I have tried in a Croquet 1.0 image and a much older
> image as well.
>
> I have a feeling this requires some sort of UNIX incantation, but I'm not
> sure what. Any ideas?
>
> Cheers,
> Bob
Works in MacOS 10.4.4.
What tells Network panel of System Preferences ?

Edgar



Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Bob Arning
Hi,

This is in 10.4.10 and the Network control panel shows the correct (static) IP address.

Cheers,
Bob

Edgar J. De Cleene wrote
Works in MacOS 10.4.4.
What tells Network panel of System Preferences ?

Edgar
Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Edgar J. De Cleene



El 10/7/07 8:27 AM, "Robert Arning" <[hidden email]> escribió:

>
> Hi,
>
> This is in 10.4.10 and the Network control panel shows the correct (static)
> IP address.
>
> Cheers,
> Bob

Very strange...
I remember some similar when I change cable modem service.
You have some local Lan with small router ?

Edgar



Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Bob Arning
Not a router, just two simple-minded hubs. This configuration has been stable for years.

I just tried an experiment using an older VM (3.5.0b3) and that VM is able to answer the localHostAddress correctly.

Cheers,
Bob

Edgar J. De Cleene wrote
Very strange...
I remember some similar when I change cable modem service.
You have some local Lan with small router ?

Edgar
Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

Bob Arning
In reply to this post by Bob Arning
One other tidbit -

After localHostAddress returns the zeros,

NetNameResolver resolverStatus ==> 3

which means:
        ResolverError := 3. "resolver idle, last request failed"

Cheers,
Bob

Robert Arning wrote
I haven't tried this in a while (previous computer), but I'm not able to get the address of my computer.

NetNameResolver localHostAddress ==> a ByteArray(0 0 0 0)
Reply | Threaded
Open this post in threaded view
|

Re: localHostAddress

johnmci
In reply to this post by Jason Johnson-5

On Oct 6, 2007, at 11:42 PM, Jason Johnson wrote:

> I would have to see your /etc/hosts.conf but you are pinging
> "Otter.local" which does look like an external (i.e. not localhost)
> address.  If you have more then one entry for Otter that points to
> different interfaces then this could happen.



[otter:~] johnmci% cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
[otter:~] johnmci% hostname
Otter.local
[otter:~] johnmci%


Well the computer name is set to otter, and os-x then cheerfully sets  
the hostname to Otter.local using
Bonjour, formerly Rendezvous, aka zeroconf

See http://en.wikipedia.org/wiki/.local

later when squeak asks for the hostname via gethostname we get back
Otter.local

On a linux system without zeroconf the interaction would be different  
and you would expect to get back an entry in the /etc/hosts

/* 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;
}




--
========================================================================
===
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===