Getting cross-platform IP address
Alex Rice
alrice at arcplanning.com
Wed Aug 27 14:02:55 EDT 2003
On Wednesday, August 27, 2003, at 04:15 PM, Dar Scott wrote:
> On Wednesday, August 27, 2003, at 03:09 PM, Scott Slaugh wrote:
>> The address function should work without a connection to the
>> internet. However, the hostNameToAddress() function does a DNS
>> lookup, and as such requires an internet connection to work properly.
>> (See the entry in the Transcript Dictionary for hostNameToAddress
>> for more information about this.)
I speculate it won't *necessarily* do a DNS lookup. It depends how the
name service resolver is configured. On Mac OS X the resolver will use
Appletalk and Netinfo first, then DNS. On Unix it can use the
/etc/hosts file, then DNS, depending on the ordering in the file
/etc/resolv.conf. YP/NIS and maybe others could be involved too.
On my OS X , "the address" returns "localhost:/...". localhost is
resolved as the loopback address, 127.0.0.1, which can't be decided by
a DNS server.
> What if I don't even know my host name or I have none or my DNS
> doesn't know it?
>
> I think the goal is to get the primary IP address of the computer not
> of a connection. I may be confused there, too.
But is there such thing as really a primary IP address? There is a
default gateway for each network interface. There can be priorities
assigned to different routes. However, the particular interface to use
isn't decided until the OS needs to send some particular network
packets and the OS goes- ok little packet: where's that network-
where's that default gateway- what's the route's priority hm.. hm...
you go out this interface.
Maybe this is why hostAddress requires a socket to be opened- it is
only capable of answering the endpoint IPs of that one socket.
--
BTW is this a documentation error in "the address"?
" Cross-platform note: On Unix systems, the computer's name is its
domain name. On Mac OS systems, the name is the one set in the File
Sharing control panel."
re: the Unix computer's name. AFAIK it depends on the contents of
/etc/hosts which usually isn't going to be domain name, it's going to
be localhost plus one or more aliases. On Mac OS X, the statement could
be true, if "the address" returned the rendezvous domain for the
computer, e.g. darkstar.local (a local domain name for my computer with
the name darkstar). But it doesn't return the rendevous name.
Alex Rice, Software Developer
Architectural Research Consultants, Inc.
http://ARCplanning.com
More information about the use-livecode
mailing list