bugfix: don't use string.format to concat binary string

This commit is contained in:
Cloud Wu
2014-07-25 21:10:11 +08:00
parent 19e6462376
commit a56b6aa425
3 changed files with 15 additions and 17 deletions

View File

@@ -8,10 +8,9 @@ local fd = assert(socket.connect("127.0.0.1", 8888))
local function send_package(fd, pack)
local size = #pack
local package = string.format("%c%c%s",
bit32.extract(size,8,8),
bit32.extract(size,0,8),
pack)
local package = string.char(bit32.extract(size,8,8)) ..
string.char(bit32.extract(size,0,8))..
pack
socket.send(fd, package)
end