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

KIU Shueng Chuan nixchuan at gmail.com
Wed May 29 03:34:27 CEST 2013


Would it make sense to deprecate socket_t::recv(void *buf) and
socket_t::send(void *buf) ?
The implementation of zmq_recv() and zmq_send() in zmq.cpp just copies
from/to a zmq_msg_t anyway.



On Wed, May 29, 2013 at 4:56 AM, Pieter Hintjens <ph at imatix.com> wrote:

> 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
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130529/d75ce15a/attachment.htm>


More information about the zeromq-dev mailing list