zeromq / azmq

C++ language binding library integrating ZeroMQ with Boost Asio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run on Mac

stephendliang opened this issue · comments

When I try to run the demo example listed in the readme (a carbon copy), there is a runtime error. When I checked what it was, it turned out to be an exception thrown due to a failure on the 'receive(const MutableBufferSequence & buffers, flags_type flags = 0)' function.

I then changed it to the code listed below

#include <azmq/socket.hpp>
#include <boost/asio.hpp>
#include

namespace asio = boost::asio;

int main(int argc, char** argv) {
asio::io_service ios;
azmq::sub_socket subscriber(ios);
subscriber.connect("tcp://127.0.0.1:5556");
subscriber.set_option(azmq::socket::subscribe("NASDAQ"));

azmq::pub_socket publisher(ios);
publisher.bind("tcp://127.0.0.1:5556");

std::array<char, 256> buf;
for (;;) {
    auto size = subscriber.receive(asio::buffer(buf));
    publisher.send(asio::buffer(buf));
}
return 0;

}

In this code, the ports are synced properly. The same exception still is thrown. However, I checked my debugger, and it seems like TCP sockets were opened and packets sent through, just that the function failed.

I built from source on Mac OS Sierra (according to the instructions on the readme), and am not sure why this is not working. The raw C examples from the zeroMQ site seem to work fine (with the zmq.h header only). My ASIO also works fine when not doing in conjunction with ZMQ.

For more specific reference, my LLDB says:

libc++abi.dylib: terminating with uncaught exception of type boost::system::system_error: Interrupted system call for the receive function...