17.12.2018, 12:42
You can also add some logging to see what's going on between devices:
Code:
function tcpsend(cmd, retry)
local sock = tcpconnect()
if sock then
local res, err = sock:send(cmd)
if res then
res, err = sock:receive()
if res then
alert('receive ok: %s', tostring(res))
else
alert('receive failed: %s', tostring(err))
end
else
alert('send failed: %s (retry: %s)', tostring(err), tostring(retry))
end
-- send failed, retry once
if not res and not retry then
tcpclose()
tcpsend(cmd, true)
end
end
end