Getting the local IP address! (was Re: Scanning machines on a network)
andu
undo at cloud9.net
Fri Mar 15 01:12:01 EST 2002
Dar Scott wrote:
>
> On Monday, March 11, 2002, at 06:09 PM, Sarah Reichelt wrote:
>
> > Here is a script to get your local IP address and store it in a field:
> >
> > local testSock
> >
> > on mouseUp
> > put line 1 of hostnametoaddress("yahoo.com")& ":80|testSocket" \
> > into testSock
> > open socket to testSock with message "socketReady"
> > end mouseUp
> >
> > on socketReady pSock
> > put hostAddress(pSock) into fld "Local IP address"
> > close socket testSock
> > end socketReady
>
> Here is a script that works on Windows 2000. I rejected it
> earlier, because it did not work on OS X. Since other features of
> UDP that work on W2K also work on Mac OS 9 (I hear), this might,
> too.
>
> This method does not actually touch another computer. (The open
> for UDP does not initiate a connection dialog between computers as
> open for TCP would; the local computer simply gets ready to send
> packets and in this case none are sent.)
>
> local testSock
> on mouseUp
> put "255.255.255.255:43222" into testSock
> open datagram socket to testSock -- opens immediately on Win2K
> put hostAddress(testSock) into field "Local IP Address"
> close socket testSock
> end mouseUp
>
> This could be made into a function. Yay! I like functions.
>
> (There might be another method using "shell" or "read from process"
> but for some reason those don't seem to be supported on OS X; the
> OS X icon is crossed out for those commands in the dictionary.)
>
> Should anybody check out this script on Linux or Mac OS, I'd be
> pleased to hear how it works.
On Linux as expected it doesn't work. What exactly are you opening the
socket to and what good would that ip address be if you're not networked
as you imply or if you are networked and get your IP address from DHCP
which happens more often then not. For same machine communication
127.0.0.1 is the standard. Luckily you can not cut yourself with it.
>
> Dar Scott
> Revolution Newbie near the northern Rio Grande
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
--
____________________
Regards, Andu Novac
More information about the use-livecode
mailing list