local chuck = require("chuck")
local engine = require("distri.engine")
local socket_helper = chuck.socket_helper
local Distri = require("distri.distri")
local cthread = chuck.cthread
local worker
function on_new_client(fd)
cthread.sendmail(worker,{fd})
end
local fd = socket_helper.socket(socket_helper.AF_INET,
socket_helper.SOCK_STREAM,
socket_helper.IPPROTO_TCP)
socket_helper.addr_reuse(fd,1)
local ip = "127.0.0.1"
local port = 8010
if 0 == socket_helper.listen(fd,ip,port) then
print("server start",ip,port)
local server = chuck.acceptor(fd)
server:Add2Engine(engine,on_new_client)
Distri.Signal(chuck.signal.SIGINT,Distri.Stop)
worker = cthread.new("distri/test/worker.lua")
Distri.Run()
end
local chuck = require("chuck")
local socket = require("distri.socket")
local engine = require("distri.engine")
local clone = chuck.packet.clone
local cthread = chuck.cthread
local Distri = require("distri.distri")
--设置邮件处理函数
cthread.process_mail(engine,function (sender,mail)
local fd = table.unpack(mail)
local s = socket.stream.New(fd)
if s:Ok(4096,socket.stream.decoder.rawpacket(),function (_,msg,errno)
if msg then
s:Send(clone(msg))
else
s:Close(errno)
s = nil
end
end) then
s:SetRecvTimeout(5000)
else
s:Close()
end
end)
Distri.Run()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有