local host, port = "ulgrad.ru", 4999 local json = require('cjson.safe') local base64 = require('base64') local socket = require("socket") local tcp = socket.tcp() tcp:connect(host, port); local pack = {} pack['id'] = 'test' pack['room'] = {['temp'] = 12,['humi'] = 67} pack['cellar'] = {['temp'] = 14,['humi'] = 77} pack['weather'] = {['temp'] = 0,['humi'] = 57} pack['sensors'] = {['28:61:64:34:80:10:F4:39'] = 18,['28:61:64:35:18:1E:74:EB'] = 17,['28:61:64:35:18:3C:3D:61'] = 19} --tcp:send(base64.encode(json.encode(pack))) tcp:send('test') while true do local s, status, partial = tcp:receive() print(s or partial) print(status) if status == "closed" then break end end tcp:close()