You cannot send a lua table over the network. But binary data is string . So you need to make a message generator based on this table itself. And yet, before sending the message body, it is recommended to send its size, for example:
function parsetable(t) local res="" -- Делаем что-то с таблицей return res end function numberToByteCode(x) local line="" local res1,res2=intdiv(x,256) if res1 > 255 or res1==0 then line=string.char(res2)..line elseif res1 > 0 then line=string.char(res1)..string.char(res2)..line end while res1 > 0 do res1,res2=intdiv(res1,256) if res1 > 255 then line=string.char(res2)..line elseif res1 > 0 then line=string.char(res1)..string.char(res2)..line end end return line end function byteCodeToNumber(x) local y=0 local z=0 for n=#x,1,-1 do if z==0 then y=y+(x:sub(n,n):byte()) else y=y+(x:sub(n,n):byte())*256^z end z=z+1 end return y end function fromNumber32(n) local bytecode=numberToByteCode(n) if #bytecode > 4 then bytecode="\255\255\255\255" elseif #bytecode < 4 then bytecode=string.rep("\0",4-#bytecode)..bytecode end end function format(msg) return fromNumber32(#msg)..msg end function get() local size=byteCodeToNumber(receive(4)) return receive(size) end function sendparsed(ip,port,t) send(ip,port,format(parsetable(t))) end
Thus, the maximum message length will be ~ 4 GB, and special characters will not interfere with message transmission.
stringtype, then there's nothing to be done about it, just translate. Or use another API / library / write your own version. - zed