[zeromq-dev] Query on zmq_poll API

Badhrinath Manoharan badhrim at gmail.com
Fri Aug 22 00:25:18 CEST 2014


Thanks Kiu. It did work fine. There was a small issue with my code. In the
example I see multiple clients created from different threads. I hope this
should also work fine if the clients are from different processes. The
broker should be able to poll inputs from both the clients by polling the
frontend connection right. Do you see any changes required in the broker
side if the clients are from multiple processes.

Thanks
Badhri


On Tue, Aug 19, 2014 at 4:23 AM, KIU Shueng Chuan <nixchuan at gmail.com>
wrote:

> There's a lbbroker example in the zguide. The main complexity seems to be
> in framing a proper response to the REQ sockets.
>
> http://zguide.zeromq.org/c:lbbroker
> On 19 Aug 2014 11:37, "Badhrinath Manoharan" <badhrim at gmail.com> wrote:
>
>> Hi Kiu,
>>
>> That was just a copy paste error in mail. I do have poll_items[1]
>> initialized.
>> Do you see any issue why zmq_poll API just returns only the first message
>> received on each socket.
>>
>> Thanks
>> Badhri
>>
>> Sent from my iPhone
>>
>> On Aug 18, 2014, at 5:31 PM, KIU Shueng Chuan <nixchuan at gmail.com> wrote:
>>
>> Your snippet neither initializes nor checks poll_items[1]. But no,
>> revents field doesn't need to be reset (nor initialized).
>>
>>
>> On Tue, Aug 19, 2014 at 8:14 AM, Badhrinath Manoharan <badhrim at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> 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?
>>>
>>> Thanks
>>> Badhri
>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140821/3f6cd622/attachment.html>


More information about the zeromq-dev mailing list