[zeromq-dev] Query on zmq_poll API

Badhrinath Manoharan badhrim at gmail.com
Tue Aug 19 02:14:19 CEST 2014


I have the following topology

Client ---> Broker ----> Server

Both the client and server are sockets of type ZMQ_REQ while the Broker has
a socket connected to client and another Socket Connected to Server both
are of type ZMQ_BROKER.

    void *frontend = zmq_socket (context, ZMQ_ROUTER);
    void *backend = zmq_socket (context, ZMQ_ROUTER);

    zmq_bind(frontend, "ipc:///users/badmanoh/frontend.ipc");
    zmq_bind(backend, "ipc:///users/badmanoh/backend.ipc");

    poll_items[0].socket = frontend;
    poll_items[0].fd = 0;
    poll_items[0].events = ZMQ_POLLIN;
    poll_items[0].revents = 0;

    poll_items[0].socket = backend;
    poll_items[0].fd = 0;
    poll_items[0].events = ZMQ_POLLIN;
    poll_items[0].revents = 0;

    while (1) {
        ret = zmq_poll(poll_items, 2, -1);
        if (ret == -1) {
            printf("zmq_poll returned -1. Error: %d\n", errno);
            return 0;
        if (poll_items[0].revents & ZMQ_POLLIN) {
        if (poll_items[0].revents & ZMQ_POLLIN) {

On the broker code, I have a zmq_poll(poll_items, 2, -1) on a while loop. I
see the zmq_poll notifying the first message from each socket. However
subsequent messages from both the client or server sockets are not at all
returned and the zmq_poll just stays in an infinite loop. Could you let us
know if I am missing anything? Do I need to reset the revents value as part
of the first notification?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140818/03e28e28/attachment.html>

More information about the zeromq-dev mailing list