[zeromq-dev] Multi-part messages API

Martin Sustrik sustrik at 250bpm.com
Sun Apr 11 10:33:51 CEST 2010


Hi all,

The current trunk now fully supports multi-part messages.

To send a multi-part messages, use ZMQ_SNDMORE flag when sending all but 
the last part of the message:

zmq::message_t part1;
zmq::message_t part2;
s.send (part1, ZMQ_SNDMORE);
s.send (part2);

On the receiver side recv the messages as normal. To find out whether 
there are more message parts to be received, use ZMQ_RCVMORE socket option:

while (true) {
    s.recv (&msg);
    uint64_t more;
    size_t sz = sizeof (more);
    s.getsockopt (ZMQ_RCVMORE, &more, &sz);
    if (!more)
        break;
}

Not to break the language bindings that define obsoleted ZMQ_MORE 
constant, the constant is still present and synonymous with ZMQ_SNDMORE.

However, it will be removed for 2.0.7 release and thus the bindings 
should be modified to expose ZMQ_SNDMORE and ZMQ_RCVMORE instead of 
ZMQ_MORE.

Martin



More information about the zeromq-dev mailing list