首页 > 其他 > 详细

luarocks cqueues

时间:2021-07-17 11:07:37      阅读:18      评论:0      收藏:0      [点我收藏+]

记录使用luarocks cqueues时碰到的一些问题:

1. 

 

2. cqueues socket 实现 I/O多路复用

function myfunc()

local cqueues = require("cqueues").new()
local server = require("cqueues.socket").listen({
host = "0.0.0.0",
port = "3456",
reuseaddr = true,
reuseport = true
})

local con = cqueues:wrap(function()
for cli in server:clients() do

print(cli:peername())

local cq = require("cqueues").new()
cqueues:wrap(function()
cq:loop()
end)
cq:wrap(function()
local buf=""
repeat
buf = cli:read()
local host, port = select(2, cli:peername())
print("recv from "..host..":"..port.." buf = ",buf)
until #buf == 0
end)

end
end)

assert(cqueues:loop())
end

luarocks cqueues

原文:https://www.cnblogs.com/jiguang321/p/15021963.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!