There are examples in the Guide where a zmq_msg_t is received and then the same variable is later used in a zmq_msg_send() call. So I assume this usage is acceptable (assuming no differences in behaviour to the version you are using).<div>

<br></div><div>obvious things to check:</div><div>- be careful to not muck around with the buf array after calling zmq_msg_send()</div><div>- receiving/sending multipart messages</div><div>- return values of zmq calls<br clear="all">

<div><br></div><div>Cheers.</div><div>--------------------</div><div>Alexander Sideropoulos</div><div><a href="mailto:alexander@thequery.net" target="_blank">alexander@thequery.net</a></div><br>
<br><br><div class="gmail_quote">On Wed, Sep 19, 2012 at 9:15 AM, Andrew Hume <span dir="ltr"><<a href="mailto:andrew@research.att.com" target="_blank">andrew@research.att.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word">i have a situation where i sometimes store messages for a while before sending on.<div>is this code safe (in terms of message handling)?</div><div><br></div><div><span style="white-space:pre-wrap">     </span>zmq_msg_t msg, buf[2000];</div>

<div><br></div><div><span style="white-space:pre-wrap"> </span>zmq_msg_init(&msg);</div><div><span style="white-space:pre-wrap">  </span>zmq_recv(sock, &msg, 0);</div><div><span style="white-space:pre-wrap">     </span>if(cond)</div>

<div><span style="white-space:pre-wrap">          </span>buf[i++] = msg;</div><div><span style="white-space:pre-wrap">  </span>else</div><div><span style="white-space:pre-wrap">             </span>zmq_msg_close(&msg);</div><div><br></div>

<div><span style="white-space:pre-wrap">  </span>...</div><div><br></div><div><span style="white-space:pre-wrap">     </span>for(j = 0; j < i; j++){</div><div><span style="white-space:pre-wrap">               </span>zmq_send(osock, &buf[j], 0);</div>

<div><span style="white-space:pre-wrap">          </span>zmq_msg_close(&buf[j]);</div><div><span style="white-space:pre-wrap">      </span>}</div><div><br></div><div>initial evidence indicates stuff is happening behind my back but before i spend</div>

<div>a lot of time debugging that, i wanted to ensure that this is even possible.</div><div><br></div><div>thanks</div><div><br></div><div><span style="white-space:pre-wrap">        </span><br><div>
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:'Lucida Grande';word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:'Lucida Grande';word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">

<br>------------------</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Andrew Hume <span> </span>(best -> Telework) <a href="tel:%2B1%20623-551-2845" value="+16235512845" target="_blank">+1 623-551-2845</a></div>

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><a href="mailto:andrew@research.att.com" target="_blank">andrew@research.att.com</a> <span> </span>(Work) <a href="tel:%2B1%20973-236-2014" value="+19732362014" target="_blank">+1 973-236-2014</a></div>

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">AT&T Labs - Research; member of USENIX and LOPSA</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><br>
</div>
</span></span></div></span></span><br></span><br>
</div>
<br></div></div><br>_______________________________________________<br>
zeromq-dev mailing list<br>
<a href="mailto:zeromq-dev@lists.zeromq.org">zeromq-dev@lists.zeromq.org</a><br>
<a href="http://lists.zeromq.org/mailman/listinfo/zeromq-dev" target="_blank">http://lists.zeromq.org/mailman/listinfo/zeromq-dev</a><br>
<br></blockquote></div><br></div>