[zeromq-dev] ZMQ_FD with request sockets
Francois-Xavier Bourlet
fx at dotcloud.com
Fri Dec 9 01:14:43 CET 2011
You don't need to call recv right after any send, but when you want to
receive something, you need to call recv before trying to wait for any
events. In the case recv failed with a tryagain error, you can then
wait for an event.
On Thu, Dec 8, 2011 at 4:05 PM, Yi Ding <yi.s.ding at gmail.com> wrote:
> OK, thanks, so I have to call recv immediately every time I call send?
> That makes it a bit difficult to reconcile with my other codepaths
> (which are all handlers coming off of a select statement)
>
> On 12/8/2011 1:33 PM, Francois-Xavier Bourlet wrote:
>> Hi,
>>
>> The keyword is: edge-triggered.
>>
>> You need to wait only if you can't read anything from the socket
>> anymore. To do so, always read using NOBLOCK, and in the case you get
>> a TRYAGAIN error, then you wait via your select/ioloop whatever.
>>
>> Regards,
>>
>> On Thu, Dec 8, 2011 at 7:59 AM, Yi Ding <yi.s.ding at gmail.com> wrote:
>>> Hi everyone,
>>>
>>> New Zeromq user here. Please bear with me if the answer to this
>>> question is blindingly obvious.
>>>
>>> I'm trying to use zeromq with select/epoll so that I can have a single
>>> thread multiplex between different inputs. After reading the
>>> documentation on ZMQ_FD, I found that it works for ZMQ_REP sockets but
>>> not for ZMQ_REQ sockets.
>>>
>>> I've basically modified the hello world server and client (the waitForIt
>>> function is the same in both files):
>>>
>>> Server code: http://pastebin.com/eBNaSVYC
>>> Client code: http://pastebin.com/ivt1xfa0
>>>
>>> What happens is that the server (ZMQ_REP) gets the request and sends a
>>> reply, but the client (ZMQ_REQ) never gets signaled for the reply, so
>>> the select times out.
>>>
>>> If we change the client to not use select, or use the default client,
>>> everything works fine.
>>> Working client code: http://pastebin.com/sg5QyZC2
>>>
>>> Reading through the list, I also tried changing the client from ZMQ_REQ
>>> to ZMQ_DEALER, but that didn't work either.
>>>
>>> Does anyone know why the file descriptor for ZMQ_REP gets triggered but
>>> the file descriptor for ZMQ_REQ does not? Is this a bug, or am I doing
>>> something wrong?
>>>
>>> I'm running ZeroMQ 2.1.10 on Linux with GCC 4.4.
>>>
>>> Thanks in advance,
>>> Yi
>>> _______________________________________________
>>> 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
--
François-Xavier Bourlet
More information about the zeromq-dev
mailing list