[zeromq-dev] Blocking when receiving multipart messages

Luca Boccassi luca.boccassi at gmail.com
Wed Aug 8 12:17:48 CEST 2018

On Wed, 2018-08-08 at 10:58 +0100, Al Grant wrote:
> I'm receiving multipart messages on a SUB socket and I want to make
> my
> code non-blocking. The docs say that a multipart message is delivered
> atomically. Can I read that as a guarantee that, if there is a 'more'
> indication
> after a previous part, a zmq_recv() on the next part will never block
> but
> immediately read the next part?
> If I can rely on that guarantee then I only need to use ZMQ_DONTWAIT
> on
> the first part, and once that succeeds I can read the whole multipart
> message
> atomically without blocking. But that guarantee doesn't seem to be
> explicitly
> stated in the docs.

Yes, messages are either delivered with all their parts to the
application receive queue or not at all.

> Also, the docs for zmq_msg_recv() say:
> An application that processes multi-part messages must use the
> zmq_getsockopt(3) <http://api.zeromq.org/3-3:zmq_getsockopt> option
> after
> calling *zmq_msg_recv()* to determine if there are further parts to
> receive.
> Wouldn't it be simpler and more efficient to use zmq_msg_more()?
> Al

You can use either, they do the same thing.

Kind regards,
Luca Boccassi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180808/be019a06/attachment.sig>

More information about the zeromq-dev mailing list