@zwh8800
2017-08-23T02:23:19.000000Z
字数 498
阅读 191252
blog 归档 lua node
lua 版的 nodejs
都听说过 nodejs 吧,最近做了个 lua 版的 nodejs。
https://github.com/zwh8800/lua-libuv
上个栗子:
local server = uv.createServer()print(server)local count = 1server:listen('0.0.0.0', 8080,function (socket, err)if socket thenprint(count .. ': ')count = count + 1print(socket)socket:write('hello lua-uv\n')socket:onData(function(socket, nread, data)if (nread >= 0) thenprint('received: ' .. data)if data == 'exit\n' thensocket:finish('bye')endelseprint('error: ' .. socket .. ': ' .. data)endend)elseprint('got nil' .. err)endend)uv.loop()
