zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.93k stars 757 forks source link

Pollers and multipart messages #544

Closed rdelfin closed 2 years ago

rdelfin commented 2 years ago

I've been looking for a way of timing out when I receive a multipart message. Unfortunately, I can't find any part of the API that shows how you'd use multipart with polling, nor any examples. Is this correct and, if so, how would one go about getting said messages? Would creating an event buffer of size 2 suffice or would that not work?

brettviren commented 2 years ago

I believe there is no special distinction needed between single and multipart messages by the poller. The zguide chapter 2 says:

ZeroMQ guarantees to deliver all the parts (one or more) for a message, or none of them

So, while our application level sees parts, the whole multipart message is handled atomically at the lower levels (my interpretation).

Then, if a poll returns saying there is a message and that message (part) has the "more" bit set, the subsequent message (part) is ready for receiving by the application immediately.

rdelfin commented 2 years ago

Thanks! Managed to get something working. Closing out