24.02.2016, 11:45
TCP function reference:
http://w3.impa.br/~diego/software/luasocket/tcp.html
Basic example:
http://w3.impa.br/~diego/software/luasocket/tcp.html
Basic example:
Code:
require('socket')
-- bravia IP
ip = '192.168.1.23'
-- IR power off command, must be 24 chars long
cmd = '*SCIRCC0000000000000000\n'
-- power-on
-- cmd = '*SCPOWR0000000000000001\n'
sock = socket.tcp()
sock:settimeout(3)
res, err = sock:connect(ip, 20060)
if res then
res, err = sock:send(cmd)
if res then
alert('send OK')
else
alert('send failed: ' .. tostring(err))
end
else
alert('connect failed: ' .. tostring(err))
end
sock:close()