[zeromq-dev] Feature request: "transmit size" on zmq_msg_t packets

Brian Granger ellisonbg at gmail.com
Thu Jun 24 08:48:49 CEST 2010

On Wed, Jun 23, 2010 at 5:28 PM, Matt Weinstein <mattweinstein at gmail.com> wrote:
> Folks,
> I'm reading variable length records directly from a MYSQL database,
> with a defined "max field length" into a dynamically allocated
> zmq_msg_t buffer, whose size must be the max field length.

Why not just create the zmq_msg_t with the shorter length in the first
place? As I understand it, creating a zmq_msg_t from existing data is
pretty quick and cheap (does not copy).  I don't think it should be a
problem to create a new zmq_msg_t for each send or recv you do, so you
can always set the size to the actual size of the message, not the max
field length.


> However, I need to send just the characters I retrieved from the
> database, not the full buffer, otherwise I must figure out how to send
> the data field size to the distant end, or at least I must:
> 1) null the unused portion of the buffer; or
> 2) copy to a smaller zmq_msg_t.
> Both of these require fill or copy operations :-(
> What I'd like is to be able to set the "transmit size" of the packet
> to a different value, e.g.
>        zmq_msg_transmit_size(&msg, transmit_size);
> Only transmit_size bytes would be sent to the distant host, and a
> zmq_msg of that size would be received.
> This would not change the size of the underlying buffer, and could be
> reset to a different N between 0<=N<=zmq_msg_size(&msg) at any time
> until it was in transit.
> Any thoughts as to whether this would be generally worthwhile, and how
> deeply the size is ingrained within the code layers?
> Thanks,
> Best,
> Matt
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com

More information about the zeromq-dev mailing list