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

Pieter Hintjens ph at imatix.com
Tue May 28 22:56:57 CEST 2013


Makes sense to me; zero is not a valid error code in any case and that
return statement is totally inconsistent with the previous one (nbytes
>= 0).

-Pieter

On Tue, May 28, 2013 at 9:17 PM, Christian Kögler <ck3d at gmx.de> wrote:
> 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
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list