Public ip address

Alex Tweedly alex at
Sat Jul 24 20:22:28 CDT 2004

At 02:37 25/07/2004 +0200, Pierre Sahores wrote:

>Seems OK there, at least from within the messagebox (Rev 2.1.2 / 2.2.1 / 
>Panther 10.3.4)
>The test "answer hostNameToAddress("")" returns the two 
>Google's dns.

I'd be comfortable that would always work - that's what's documented :-)

My example was using an empty string for host (i.e. fully qualified domain 
name) - which I expected would default to the local machine, though the 
docs don't specify it.

As I later realized, the original request was for a way to get
>the ip address provided by the ISP

which I interpret as "the IP address facing the internet" or "... attached 
to the internet". It will only be provided by the ISP in the case of an 
interface directly connected to a dial-up, broadband or similar network.

If you have such a machine, and it has no other active IP interface, then 
I'd expect hostNameToAddr("") to give the correct value (though I can't 
verify whether it does right now).

If you have a machine which is connected only to a local network (e.g. 
behind a DSL router, or on  a private local net) then I'd expect that to 
also work.

But if you had a machine with multiple IP interfaces (e.g. a Windows 
machine attached to a DSL line and running Windows Internet Connection 
Sharing, or a Linux box configured as a router), then I don't know if it's 
predictable which interface address you'd get back. I'd *expect* it to be 
the lowest numbered IP address (though  I wouldn't guarantee it), and that 
may well not be the one that is attached to the internet.

Dar's solution of opening a UDP socket to a public address should always 
get the IP address of an interface which can reach the internet.

But then we come back to the intent of the original question ....
Roger - why do you want to get the IP address, and what kind of thing do 
you want to use it for ?  The reason it matters is the possibility of there 
being a NAT box between the local machine and the internet - in which case 
the local IP address may well not be addressable from the internet.

-- Alex.
-------------- next part --------------

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004

More information about the use-livecode mailing list