Why No Built in GetMyIP call in LiveCode?

Nonsanity form at nonsanity.com
Fri Jun 10 15:06:07 EDT 2011


In my last code, the localhost was just to get the hostName, something that
can also be done with LC's built in hostName function/prop like so:

put char 2 to -2 of word 3 of shell( "ping -n 1" && the hostName ) into msg

It's just an optional way to get the hostName if LC was failing to do that
properly for some reason. But pinging your hostName will be sure to return
the IP address other computers on the LAN will see you as.

One-twenty-seven
Zero dot zero dot one
There's no place like home

 ~ Chris Innanen
 ~ Nonsanity


On Fri, Jun 10, 2011 at 2:53 PM, Bob Sneidar <bobs at twft.com> wrote:

> Or don't use localhost at all! It will always return 127.0.0.1. That is the
> loopback address of every adapter under the sun.
>
> Bob
>
>
> On Jun 10, 2011, at 11:49 AM, Nonsanity wrote:
>
> > haha I completely failed to grasp that. :)
> >
> > How about:
> >
> > put char 2 to -2 of word 3 of shell( "ping -n 1" && word 2 of shell("ping
> -n
> > 1 localhost") ) into msg
> >
> > ~ Chris Innanen
> > ~ Nonsanity
> >
> >
> > On Fri, Jun 10, 2011 at 2:20 PM, John Patten <johnpatten at mac.com> wrote:
> >
> >> Actually Chris I wanted the local network, behind the firewall IP
> address.
> >> The project I have in mind is just using sockets in a single classroom.
> All
> >> computers have 10.x.x.x. addresses.
> >>
> >> Thanks!
> >>
> >> John Patten
> >> SUSD
> >>
> >>
> >>
> >> On Jun 10, 2011, at 11:15 AM, Nonsanity wrote:
> >>
> >> Neither of the solutions given so far in this thread have worked for my
> on
> >>> my office PC. I just get my LAN 192.168.x.x number. Here's what I use.
> >>> They
> >>> do rely on outside entities, but they are both pretty stable sites that
> >>> have
> >>> lasted a good long time...
> >>>
> >>> [whatismyip.org]
> >>> put url "http://www.whatismyip.org" into myExIP
> >>>
> >>> [dyndns.org]
> >>> put url "http://checkip.dyndns.org" into resp
> >>> set itemdel to ":"
> >>> put word 1 to -1 of item 2 of resp into resp
> >>> set itemdel to "<"
> >>> put item 1 of resp into myExIP
> >>>
> >>>
> >>> ~ Chris Innanen
> >>> ~ Nonsanity
> >>>
> >>>
> >>> On Fri, Jun 10, 2011 at 1:05 PM, John Patten <johnpatten at mac.com>
> wrote:
> >>>
> >>> Hi All...
> >>>>
> >>>> I've been looking at all the solutions in the archive for getting the
> IP
> >>>> address of the machine running a stack. Some shell scripts, some php
> >>>> calls,
> >>>> etc. etc.
> >>>>
> >>>> I have a situation where we are behind a firewall using NAT. So all
> our
> >>>> computers are running a 10.x.x.x.x address. I'm trying to implement
> some
> >>>> socket communication between stacks and IP address information is
> >>>> essential
> >>>> for this to work. I would like the communication process set up to be
> as
> >>>> transparent as possible, allowing users to connect by name and maybe
> >>>> holding
> >>>> IP address is a custom property for example.
> >>>>
> >>>> The Dictionary provides some examples for hostAdress function and I
> tried
> >>>> (wishful thinking, script trickery) something like this:
> >>>>
> >>>> on mouseUp
> >>>> open socket to "127.0.0.1:5005" with message "socketOpen"
> >>>> put the result
> >>>> end mouseUp
> >>>>
> >>>> on socketOpen theSock
> >>>> put the hostAddress of "127.0.0.1:5005"
> >>>> end socketOpen
> >>>>
> >>>> ...but it just gave me 127.0.0.1 and not the 10.x.x.x. address...
> >>>>
> >>>>
> >>>> Shell script works nice, but it gives quite a few IP in its result.
> Plus
> >>>> the actual machine IP is located on different lines in the result,
> such
> >>>> as
> >>>> in a desktop machine, as opposed to a laptop on wireless.
> >>>>
> >>>> It just seems like it would be nice to have a built in function for
> >>>> reporting local machine's IP...
> >>>>
> >>>> Such as, "put localIP of current stack into tIP"  or "get LocalIP of
> >>>> current stack."
> >>>>
> >>>> Is this available in the dictionary and I'm just missing it?
> >>>>
> >>>> Thank you!
> >>>>
> >>>> John Patten
> >>>> SUSD
> >>>> _______________________________________________
> >>>> use-livecode mailing list
> >>>> use-livecode at lists.runrev.com
> >>>> Please visit this url to subscribe, unsubscribe and manage your
> >>>> subscription preferences:
> >>>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>>>
> >>>> _______________________________________________
> >>> use-livecode mailing list
> >>> use-livecode at lists.runrev.com
> >>> Please visit this url to subscribe, unsubscribe and manage your
> >>> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>>
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list