[zeromq-dev] Multi-part messages

Martin Sustrik sustrik at 250bpm.com
Sat Mar 27 15:12:48 CET 2010

Hi all,

I've implemented "multi-part message" functionality as it was discussed 
on the mailing list lately.

The patch was committed to the trunk and can be used this way:

zmq::message_t part1 (100);
s.send (part1, ZMQ_TBC); //  to be continued...
zmq::message_t part2 (100);
s.send (part2);

Multi-part message behaves as a simply message. Specifically, it's 
atomic, meaning that you'll either get all parts or nothing. Also 
individual parts of the message cannot be torn apart by load balancing, 
fair queueing etc.

As for the use cases, multi-part messages allow to create a message 
zero-copy style from several non-contiguous memory bocks - this is 
similar to scatter/gather arrays in Berkeley sockets.

Another use case is adding structure to the message. Message part 
boundaries are preserved as message passes the network, thus they can be 
used to delimit semantically separate parts of the message. This use 
case is going to be used extensively by 0MQ itself in the future 
(separating routing info from user data etc.)

The patch is quite complex and thus it would benefit from testing.

Also note that XREQ and XREP sockets are rendered unfunctional by the 
patch and will be rewritten shortly.


More information about the zeromq-dev mailing list