09.10.2017, 14:29
(09.10.2017, 14:06)sorin Wrote: Hi,
I need a resident script that ping an IP , and if does not receive any reply to open a actuator.
Please help
Thanks a lot!
Here you are:
Code:
function socketping(ip, port, timeout)
port = port or 80
local sock = require('socket').tcp()
sock:settimeout(timeout or 2)
local res, err = sock:connect(ip, port)
sock:close()
return res, err
end
ip = '192.168.2.1'
if not socketping(ip) then grp.write('1/2/3', true) end