Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

cpu 100% when use zmq recv() #23

Open
daogangtang opened this Issue Nov 2, 2012 · 0 comments

Comments

Projects
None yet
1 participant

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:1235')
local pub = zmq:socket(luv.zmq.PUSH)
pub:bind('tcp://127.0.0.1:1235')
print("enter cons")

while true do

print('xxxxxx')
local msg = sub:recv()
print('yyyyyyxxxxxx')
-- require('posix').sleep(1)
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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment