Open miketang84 opened 11 years ago
mind to submit the whole test?
hi, I paste here,
1.
local luv = require('luv')
local zmq = luv.zmq.create(2)
local cons = luv.fiber.create(function() local sub = zmq:socket(luv.zmq.PULL) sub:connect('tcp://127.0.0.1:1234')
local pub = zmq:socket(luv.zmq.PUB) pub:bind('tcp://127.0.0.1:12315') --local pub = zmq:socket(luv.zmq.PUSH) --pub:bind('tcp://127.0.0.1:1235') print("enter cons")
while true do local msg = sub:recv() if msg then print(msg) --pub:send('haha, I have receive your request '.. msg) --pub:send(msg) pub:send('I like you '..math.random()) end --luv.sleep(1) end sub:close() pub:close() end)
cons:ready() cons:join()
2.
local luv = require('luv')
local zmq = luv.zmq.create(2)
local pub = zmq:socket(luv.zmq.PUSH) pub:bind('tcp://127.0.0.1:1234') local sub = zmq:socket(luv.zmq.SUB) sub:connect('tcp://127.0.0.1:12315') sub:setsockopt("SUBSCRIBE", '') --[[ local sub = zmq:socket(luv.zmq.PULL) sub:connect('tcp://127.0.0.1:12315') --]]
local prod = luv.fiber.create(function()
print("enter prod:") luv.sleep(3) local i = 1 while i > 0 do
pub:send("tick: "..i)
luv.sleep(1)
i=i+1
end --pub:close() end) prod:ready()
local ss = luv.fiber.create(function() print("enter ss:") while true do print('ready to receive.') local msg = sub:recv() print(msg) luv.sleep(1) end
end)
prod:ready() ss:ready() ss:join()
On Sun, Oct 14, 2012 at 4:07 PM, Vladimir Dronnikov < notifications@github.com> wrote:
mind to submit the whole test?
— Reply to this email directly or view it on GitHubhttps://github.com/richardhundt/luv/issues/15#issuecomment-9417212.
Nothing is impossible.
hi, I wrote a pub/sub test,
pub:
local pub = zmq:socket(luv.zmq.PUB) pub:bind('tcp://127.0.0.1:12315')
sub:
local sub = zmq:socket(luv.zmq.SUB) sub:connect('tcp://127.0.0.1:12315') sub:setsockopt("SUBSCRIBE", '')
pub:send(msg) can work, bug sub:recv() is blocked always, no data returned.
can you check it?