[zeromq-dev] docs, ownership sockopts

Martin Sustrik sustrik at 250bpm.com
Mon Jan 16 23:21:32 CET 2012


On 15/01/12 12:10, john skaller wrote:

> Who owns the binary data blobs using set_sockopts? And get_socopts while I'm asking.
> For identity, subscribe, unsubscribe?
>
> I presume the caller owns them for all the others, so the function must
> copy the int, uint64 etc. I assume set_sockopts copies the blobs
> with malloc. In that case, how is it freed?

When you set a blob option, 0MQ makes a copy of it. The buffer you pass 
in is owned by you and 0MQ doesn't try to free it or similar.

> If not .. how do I free it?
>
> I'm currently passing C++ string.c_str() for the blobs on set,
> and will init a string on get ..  will that work?

When you get a blob option, 0MQ copies the value of the option to the 
buffer you supply. It doesn't try to allocate it or similar.

Martin



More information about the zeromq-dev mailing list