Getting the local IP address! (was Re: Scanning machines on a network)

Dar Scott dsc at
Fri Mar 15 04:30:01 EST 2002

On Friday, March 15, 2002, at 01:14 AM, andu wrote:

> Connecting to your router should do, then. The idea is that if you 
> don't
> want to or can't use built-in tools like ipconfig/ifconfig (must 
> be some
> way for Mac too) you must use some external reference point to find out
> the IP address.

There's the rub.

You have helped me get my thoughts together on this:

A nice solution would be platform independent.  Using a different 
method for each platform is awkward.  The next platform might not 
be included.

The ipconfig/ifconfig solution is reliable, but will only work on 
two classes of platforms.  There is no shell command for Rev on OS 
X yet, it seems.

The hostAddress() of a UDP socket to a broadcast address works for 
W2K, but (assuming I understood Andu right) does not work for Linux.

The hostAddress() of a UDP socket to a public IP address will 
probably only work if the computer knows a gateway to the 
Internet.  I worry the open would fail if there is only a closed 
LAN.  (I haven't tested this.)

The hostAddress() of a UDP socket to an arbitrary private address 
might fail for the same reason; it is not likely to be in the local 

If a person writes a stack and has no idea of the what LAN it will 
eventually run on, how does that stack get the local IP?

It looks to me that there is no good way to get the local IP 
address in Revolution.

Thanks Andu for letting me know about hostAddress of a UDP socket 
to a boardcast address not working on Linux.  And thanks for 
helping me think through this.


More information about the use-livecode mailing list