Getting cross-platform IP address

Dar Scott dsc at swcp.com
Wed Aug 27 15:12:00 EDT 2003


On Wednesday, August 27, 2003, at 01:38 PM, Rob Gould wrote:

> I must be missing something obvious, but is there a command that 
> provides the user's IP address (whether Mac or PC).
>
I'm collecting ways to do this, so I'd be pleased to see answers.

I think Ken Ray has some shell() solutions at his web site for OS X and 
Windows.

Another approach is to open a connection to a known Internet computer 
and look at the hostAddress() of the connection and then close it.  
This will only work if you have an Internet connection and it seems to 
me to be impolite.  (Perhaps RunRev can give permission for us to use 
their http for this and this will act as motivation for a solution.)

One that should work but is blocked by a bug is to open datagram to 
some bogus but syntactically valid address.  Then check hostAddress.

I have a method that works on Windows and Mac OS 9, but not on OS X.  I 
was about to make a query to this list to see if the problem is a 
strange unix tradition or a bug in the engine or something else.

It would be cool if hostAddress() without a parameter would return a 
list of IP addresses.

Which reminds me.  The problem is complicated by the fact that the 
computer may have more than one address (beyond 127.x.x.1).

Dar Scott




More information about the use-livecode mailing list