a *fast* check for whether another machine is on the local network?
alex at tweedly.net
Fri Jun 14 22:30:01 CEST 2013
Sorry, I've been offline for a while, so this reply is coming kind of
late, but I don't think anything in the subsequent discussion
If you don't want to wait a second, you could do
(for address 10.0.0.232)
-- NB we don't care if this succeeds or not
open datagram socket to "10.0.0.232:4000"
-- if paranoid: wait for 10 ms
put shell("arp -a") into temp
filter temp with "*10.0.0.232*"
The open socket may or may not work - but it will resolve the IP address
first, and hence get an entry in the arp table. Then you can check
variable 'temp' to verify the IP address is there, and that it has an
actual mac address corresponding to it (rather than "incomplete").
NB "open datagram socket" will return without waiting for the socket to
open; I think it may do the addr resolution before returning, but you
could be cautious / paranoid and do a "wait 10 ms" before doing the arp
btw - corner case - if you have a router doing proxy arp replies (e.g.
to handle hosts that can't do default route), then this will falsely
appear to work - but AFAIK that is a very, very uncommon situation nowadays.
On 13/06/2013 22:52, Dar Scott wrote:
> On Jun 13, 2013, at 3:02 PM, Dr. Hawkins wrote:
>> Is there a *fast* way to see if another machine is currently on the
>> local network, by name (somemachine.local) or otherwise, from within
>> There's always sending a message and waiting for it to hang, but I'd
>> like something that happens quickly.
> On OS X:
> You can use shell("arp -a") and look whether the IP address is included. The list associates the underlying Ethernet address with the IP address. It will expire after 20 minutes of non use. So, this really means this computer talked to that computer in the last 20 minutes.
> I think the best way has to involve a message. To keep it fast, use an IP address rather than the host name. Use a method with a fast timeout.
> You might be able to use shell(" ping -c 1 -t 1 10.9.8.7") but that would take a second if the computer is not there.
> If you have a service set up on that computer then you might be able to try that.
> On Windows:
> Dar Scott
> Dar Scott Consulting
> 8637 Horacio Place NE
> Albuquerque, NM 87111
> Lab, home, office phone: +1 505 299 9497
> For Skype and fax, please contact.
> dsc at swcp.com
> Computer programming and tinkering,
> usually in supporting those developing in
> LiveCode--typically by making LiveCode
> controls, libraries and externals, and
> sometimes by writing associated
> microcontroller firmware.
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode