04.12.2018, 13:21
Hi control is working but I am get respond with timeout. why?
Command function:
Event:
Manual
Command function:
Code:
function tcp_oppo(data, ip, port)
local sock = require('socket').tcp()
sock:settimeout(3)
local res, err = sock:connect(ip, port or 23)
if res then
res, err = sock:send('#' .. data .. '\r')
if res then
res, err = sock:receive('*a')
else
alert('send failed: ' .. tostring(err))
end
else
alert('connect failed: ' .. tostring(err))
end
sock:close()
return res, err
end
Code:
ip = '192.168.11.105'
if (event.getvalue() == true) then
res, err = tcp_oppo('POW', ip)
end
log (res, err)