finding local IP?

Dar Scott dsc at swcp.com
Tue Dec 21 12:33:37 EST 2004


On Dec 21, 2004, at 2:14 AM, Thierry Arbellot wrote:

>     put "255.255.255.255:43222" into testSocket
>     open datagram socket to testSocket
>     put hostAddress(testSocket) into theIPAddress
>     close socket testSocket

I don't know what different systems might do if there are multiple 
network adaptors or multiple subnet and IP addresses to any network 
adaptor.  One might assume the primary IP address is used, whatever 
that means.

Perhaps for the the problem at hand, it might be safest to use the IP 
address of something on the LAN that is fixed, such as a router or 
server.  That way you always get the IP address to the right LAN: the 
adaptor and the right subnet.

That is, if router 172.17.0.1 is on the same subnet under 
consideration, then the line might be:

     put "172.17.0.1:444222" into testSocket

The port can be anything; this method does not put any TCP/IP activity 
on the network.


**********************************************
     DSC (Dar Scott Consulting & Dar's Lab)
     http://www.swcp.com/dsc/
     Programming Services and Software
**********************************************



More information about the use-livecode mailing list