diff --git a/README.md b/README.md index ceaa4d56..d438b558 100644 --- a/README.md +++ b/README.md @@ -23,16 +23,14 @@ Run these in different console ``` ./skynet examples/config # Launch first skynet node (Gate server) and a skynet-master (see config for standalone option) -lua examples/client.lua # Launch a client, and try to input some words. +./3rd/lua/lua examples/client.lua # Launch a client, and try to input hello. ``` ## About Lua -Skynet put a modified version of lua 5.2.3 in 3rd/lua , it can share proto type between lua state (http://lua-users.org/lists/lua-l/2014-03/msg00489.html) . +Skynet now use lua 5.3.0-rc3 , http://www.lua.org/work/lua-5.3.0-rc3.tar.gz -Each lua file only load once and cache it in memory during skynet start . so if you want to reflush the cache , call skynet.cache.clear() . - -You can also use the offical lua version , edit the makefile by yourself . +You can also use the other offical lua version , edit the makefile by yourself . ## How To (in Chinese) diff --git a/examples/client.lua b/examples/client.lua index e9efc160..a17b1926 100644 --- a/examples/client.lua +++ b/examples/client.lua @@ -1,8 +1,11 @@ package.cpath = "luaclib/?.so" package.path = "lualib/?.lua;examples/?.lua" +if _VERSION ~= "Lua 5.3" then + error "Use lua 5.3" +end + local socket = require "clientsocket" -local bit32 = require "bit32" local proto = require "proto" local sproto = require "sproto" @@ -13,10 +16,7 @@ local fd = assert(socket.connect("127.0.0.1", 8888)) local function send_package(fd, pack) local size = #pack - local package = string.char(bit32.extract(size,8,8)) .. - string.char(bit32.extract(size,0,8)).. - pack - + local package = string.pack(">s2", pack) socket.send(fd, package) end