Closed paddor closed 9 years ago
Any news on this?
Sorry for the long delay in responding. This is not a bug. The Socket#send* methods never raise exceptions. They return -1 from the method and require you to handle the error.
I modified your example to prove it.
require 'ffi-rzmq'
class ZMQTest
def initialize(addr)
@ctx = ::ZMQ::Context.create
@socket = @ctx.socket(::ZMQ::ROUTER)
warn "setting option ::ZMQ::ROUTER_MANDATORY (#{::ZMQ::ROUTER_MANDATORY}) to 1"
@socket.setsockopt(::ZMQ::ROUTER_MANDATORY, 1)
@socket.bind(addr)
end
def test
warn "sending message"
rc = @socket.send_strings(["test_client", "foo"])
rescue
warn "BAD! Sending messages should never raise an exception!"
else
warn "Failed and returned [#{rc}]. Check ZMQ::Util.errno and handle it."
end
end
ZMQTest.new("inproc://server").test
The following code provides a simple way to test if it works or not (unless I missed something). It prints
BAD! Should have raised!
on my computer.Also as gist: https://gist.github.com/paddor/70fbbce8071f6ba1288e