Getting IP Address of Machine that is Currently Running the Stack

Eric Chatonet eric.chatonet at sosmartsoftware.com
Wed Oct 25 10:28:34 EDT 2006


Hi Dave,

Here is an example that might be easier to use:

local lIPAddress -- local script variable
----------------------------------
function GetIPAddress
   local tInternetConnected
   -----
   put hostNameToAddress("www.runrev.com") <> empty into  
tInternetConnected
   if tInternetConnected then
     put empty into lIPAddress
     open socket to "www.runrev.com:443" with message "SocketOpen"
     wait until lIPAddress <> empty with messages
     return lIPAddress
   else return "Error: could not find an internet connection."
end GetIPAddress
----------------------------------
on socketOpen
   put the hostAddress of "www.runrev.com:443" into lIPAddress
   close socket "www.runrev.com:443"
end socketOpen

You will use this code easily:

put GetIPAddress() into tCurMachineIPAddress

Of course you may use another domain than www.runrev.com and another  
port than 443 as you like :-)
Have a look at hostNameToAddress, open socket,  close socket and  
hostAddress in the docs.

Best Regards from Paris,
Eric Chatonet

Le 25 oct. 06 à 16:06, jbv a écrit :

> Dave,
>
> I usually do that by sending a "get URL" request to a cgi script  
> (Rev cgi
> or php) that runs on a server and that returns the client IP.
>
> JB
>
>
>> Hi All,
>>
>> How can I get the IP address of the machine that a stack is  
>> running on?

------------------------------------------------------------------------ 
----------------------
http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/





More information about the Use-livecode mailing list