[zeromq-dev] problem: cppzmq, zero-length message send/recv, ZMQ_DONTWAIT

Christian Kögler ck3d at gmx.de
Tue May 28 21:17:40 CEST 2013

We discussed in our team to use zero-length messages. We found out, that 
C++ API cppzmq has a problem. In send/recv it is not possible to differ 
between an empty or no message, if ZMQ_DONTWAIT is used.
An example, which fails if zero-length messages are used:

char buffer[8];
while(socket.recv(buffer, sizeof(buffer), ZMQ_DONTWAIT) >= 0)
   {std::cout << "received a message" << std::endl;}
std::cout << "never reached" << std::endl;

I propose to return a negativ value and not zero ([1]), if no message 
was received (or send).

Best regards
Christian Kögler

[1] https://github.com/zeromq/cppzmq/blob/master/zmq.hpp#L392
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130528/955cda2f/attachment.htm>

More information about the zeromq-dev mailing list