On Sunday, March 06, 2011, Pieter Hintjens wrote:
> On Sun, Mar 6, 2011 at 12:21 PM, Mikko Koppanen
>
> <[email protected]> wrote:
> > as the message data is an opaque binary blob I am not sure whether
> > removing the trailing \0 is correct behaviour. If you are receiving a
> > message with a trailing \0 it means that the sender has included it as
> > a part of the message.
>
> Indeed... this seems to be a fault in the sender. The convention for
> strings encoded as 0MQ frames is to NOT include a terminating null
> byte.
>
> -Pieter
Hi,
Here's the code in the sender (C++):
zmq::message_t reply (3);
memcpy ((void *) reply.data (), "OK", 2);
socket.send (reply);
It's an almost literal copy from the guide:
// Send reply back to client
zmq::message_t reply (6);
memcpy ((void *) reply.data (), "World", 5);
socket.send (reply);
So I guess I should have reported an error in the guide.
Thanks for the prompt replies. I've reverted my patch.
Han Holl
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev