[zeromq-dev] How to get buffer out of zmq_msg
Martin Sustrik
sustrik at 250bpm.com
Wed Feb 8 01:09:53 CET 2012
Hi John,
> If you initialise the message empty, zmq_recvmsg will allocate
> exactly the right amount of space for you. This is ideal.
> But there's no way to get the buffer out of the msg, you have
> to copy it. This is wastes a memcpy, and wastes storage temporarily.
> You have to copy it because zmq_close will deallocate the buffer.
The problem is that 0mq messages are reference counted, so you may be
sharing the message buffer with others.
> Of course .. you can *cheat* and simply not close the zmq_msg_t,
> and in the current implementation I am guessing this would work.
Yes. That should work.
Martin
More information about the zeromq-dev
mailing list