3 socket Q's
sarahr at genesearch.com.au
Sun Mar 28 21:27:12 CST 2004
> 1. This returns my local IP address on all my machines not
> connected to my router:
> get hostnametoaddress(hostname())
> But behind my router it returns empty. Why?
> And what is the reliable way to obtain the local IP address?
> Hi Richard,
Do you actually want the router's address (so people can connect to you
from outside your firewall) or your own computer's address?
For getting the router's address, I log on to checkip.dyndns.org:
put "http://checkip.dyndns.org/" into theURL
put URL theURL into theData
get lineOffset("Current IP Address:", theData)
put last word of line it of theData into ipAddr
if ipAddr contains "<" then delete char offset("<", ipAddr) to -1 of
Make sure it never gets called in rapid succession or they will
For getting my internal address, I use the method Dar described of
opening a socket to a web site and then using the hostAddress function:
put empty into fld "IP address"
put line 1 of hostnametoaddress("genesearch.com.au")&
open socket to testSock with message "socketReady"
on socketReady pSock
put hostAddress(pSock) into fld "IP address"
close socket pSock
Hope this helps,
More information about the use-livecode