04.12.2018, 15:02
(04.12.2018, 14:45)admin Wrote: The remote host probably is not closing the socket after command that's why receive all (*a) is not working. You can get partial response like this:
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, partial = sock:receive('*a') else alert('send failed: ' .. tostring(err)) end else alert('connect failed: ' .. tostring(err)) end sock:close() return res, err, partial end ---------------------------------- ip = '192.168.11.105' if (event.getvalue() == true) then res, err, partial = tcp_oppo('POW', ip) end log (res, err, partial)
Thanks admin its working I get 'partial'
How you think how to do to get status of device power when device will be turn on over remote that LM will know of Player status.