Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu 100% when use zmq recv() #23

Open
miketang84 opened this issue Nov 2, 2012 · 0 comments
Open

cpu 100% when use zmq recv() #23

miketang84 opened this issue Nov 2, 2012 · 0 comments

Comments

@miketang84
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant