[zeromq-dev] zmq_msg_init_data for receive data

Claudio Bisegni cbisegni at gmail.com
Sat Mar 8 19:38:49 CET 2014


HI all,
i use the zmq_msg_t strutture for send and receive message. I use the zmq_msg_init_data to initialize message with buffer that i have already allocate. In this way i try to achieve a non-copy memory using zmq. The piece of cose that do this follow below:

err = zmq_msg_init_data(&header_msg, header_buffer, DIRECT_IO_HEADER_SIZE, ZMQDirectIOServerFree, NULL);
          
err = zmq_msg_recv(&header_msg, socket, 0);
if(err == -1 || err != DIRECT_IO_HEADER_SIZE) {
	err = zmq_msg_close(&header_msg);
	continue;
}
err = zmq_msg_close(&header_msg);

< header_buffer  is not filled>

Unfortunaly when the zmq_msg_recv (with the right reader byte) into the header_buffer is not write anythings. using the code below, obviously, all work bit it’s do a copy from the internal message strutture and my buffer.

err = zmq_recv(socket, header_buffer, DIRECT_IO_HEADER_SIZE, 0);
if(err == -1 ||  err != DIRECT_IO_HEADER_SIZE) {
  continue;
}

< header_buffer  IS filled>

It seems that is not possible to use zmq_msg_init_data in receivement mode for use non-copy memory features.
I fault in something or isn-t possible to do?

ZMQ version used is 30205 (from api)

Thanks in advanced

	Claudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140308/84c81ae5/attachment.htm>


More information about the zeromq-dev mailing list