hostNameToAddress not working???

Dave dave at looktowindward.com
Fri Feb 15 08:40:47 EST 2008


Hi,

Yes, I am using a router, actually it a different router then when  
first I tested this (about a year ago).

 From looking at the Network settings I have a LAN IP Address of  
192.168.1.87 and my router address is 192.168.1.1 and my local  
address is 127.0.0.1 and the Public IP address is 94.140.30.222. If I  
use:

> put hostaddresstoname(url "http://xtalk.memebot.com/cgi-bin/ip.cgi")


it returns the public address where as what I want is the local LAN  
Address, e.g. I want to be able to identify machines on my local  
network.

When I call the hostName() function, I get back "MachineName" this  
used to work just fine but now doesn't (either because of a change in  
RunRev or because I have a different router), however is I append  
".local" to the machine name, it returns the correct LAN address. so  
if I change my function as so:

------------------------------------------------------------------
--
--  UtilHostGetIPAddressLAN
--
------------------------------------------------------------------
function UtilHostGetIPAddressLAN
   local myHostName
   local myHostIPAddress

   put the hostName into  myHostName
   if char -7 to -1 myHostName <> ".local" then
     put ".local" after myHostName
   end if

   put hostNameToAddress(myHostName) into myHostIPAddress
   return myHostIPAddress
end UtilHostGetIPAddressLAN

It works!!!!!!!!!!

All the Best
Dave


On 15 Feb 2008, at 13:09, Mark Schonewille wrote:

> Hi Dave,
>
> The hostaddresstoname and hostnametoaddress function work fine. My  
> tiny cgi script on Memebot works fine too.
>
> I bet your machine is connected to a local network using a router.  
> It is also possible that you have additional gateways defined on  
> your local machine, e.g. to facilitate Parallels.
>
> If an IP number or address doesn't exist or is invalid, e.g.  
> because it is of the form "Machine.local", the hostaddresstoname  
> and hostnametoaddress functions may return empty. This is normal.
>
> Perhaps, you are looking for:
>
> put hostaddresstoname(url "http://xtalk.memebot.com/cgi-bin/ip.cgi")
>
> Best regards,
>
> Mark Schonewille
>
> --
>
> Economy-x-Talk Consulting and Software Engineering
> http://economy-x-talk.com
> http://www.salery.biz
>
> Convert colours between different colour spaces with Color  
> Converter. Download at http://economy-x-talk.com/cc.html
>
>
>
> Op 15-feb-2008, om 12:53 heeft Dave het volgende geschreven:
>
>> Hi All,
>>
>> I have the following function:
>>
>> ------------------------------------------------------------------
>> --
>> --  Get the LAN IP Address of this Machine
>> --
>> ------------------------------------------------------------------
>> function IPMGetHostIPAddressLAN
>>   local myHostIPAddress
>>
>>   put hostNameToAddress(the hostName) into myHostIPAddress
>>   return myHostIPAddress
>> end IPMGetHostIPAddressLAN
>>
>>
>> This used to work fine and return the local LAN address of the  
>> machine the Script is running on, I just tried it and now it just  
>> returns empty.
>>
>> I originally cribbed this from Richmond's "Get IP Address" stack.  
>> I download this again from rev online and it too fails. From this  
>> stack:
>>
>> on mouseUp
>>   put "Public IP =" && url "http://xtalk.memebot.com/cgi-bin/ 
>> ip.cgi" into line 1 of fld "F1"
>>   put "Local IP =" && hostnametoaddress ("localhost") into line 2  
>> of fld "F1"
>>   put "LAN IP =" && hostnametoaddress(the hostname)  into line 3  
>> of fld "F1"
>> end mouseUp
>>
>> When I run this I get "empty" as the LAN Address. The other two IP  
>> address fields are filled in ok.
>>
>> Could anyone shed any light on why this has stopped working and  
>> how I can obtain the LAN IP address?
>>
>> Thanks a lot
>> All the Best
>> Dave
>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>





More information about the use-livecode mailing list