[zeromq-dev] SUB abandon receiving a multipart message

Al Grant algrant at acm.org
Wed Aug 8 23:00:44 CEST 2018


Counterpart to my question about abandoning a multipart send...

A subscriber might decode part way through receiving a multipart
message, that it's not interested in the rest (and the condition isn't
simple enough to do as a topic match - or it might be a resource
issue). The subscriber needs to drain the remaining parts so that
the next zmq_recv() can get the first part of the next message.

Is there a simple way to do this? I.e. equivalent to

  while (1) {
     int more;
     zmq_getsockopt(subsock, ZMQ_RCVMORE, &more, &size_more);
     if (!more) break;
     zmq_recv(subsock, ....);     // discard the message
  }

An alternative would be to have a flag on zmq_recv() meaning
ignore any remaining parts of a multipart message and read the
next first (or only) part of a new message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180808/a693b775/attachment.html>


More information about the zeromq-dev mailing list