Bleh, this is what we get from documenting code instead of implementing API
contracts. This seems overly confusing. That makes me think this area needs
review for 3.0 as well as better documentation now.

-Pieter

On 23 Sep 2010 01:59, "MinRK" <[email protected]> wrote:
> On Wed, Sep 22, 2010 at 14:47, Pieter Hintjens <[email protected]> wrote:
>
>> On Wed, Sep 22, 2010 at 2:08 PM, Pieter Hintjens <[email protected]> wrote:
>>
>> > Strange. I remember discussing this with Martin Sustrik and hearing,
>> > "when a message is sent 0MQ nullifies it".
>>
>> OK, so the user guide is wrong on this. Sending a message is safe and
>> does not affect it. Receiving _into_ an existing message will nullify
>> the message first.
>>
>> Wires got crossed somewhere... sorry about that.
>>
>> You can send the same message N times safely.
>>
>
> I don't believe that's true, since it broke in my device code. Sending a
> message twice results in the second send being empty.
>
> send(msg) takes ownership of the contents of msg, and re-initializes msg,
> which is your *reference* to the content. You can send a message multiple
> times, as long as you copy the reference, so that you still have a
reference
> to the content after zmq clears out the one you gave to send.
>
> The following will send a bunch of empty messages:
> while true:
> socket.send(msg)
>
> This, however, will send msg as long as you like:
> # note that there will be no real copies of data, only references
> while true:
> zmq_msg_copy(&tosend, &msg)
> socket.send(tosend)
> zmq_msg_close(&tosend)
>
> Forgive the not-quite-Python pseudocode.
>
> -MinRK
>
>
>>
>> -
>> Pieter Hintjens
>> iMatix - www.imatix.com
>> _______________________________________________
>> zeromq-dev mailing list
>> [email protected]
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to