mato at kotelna.sk
Wed May 4 13:33:58 CEST 2011
ilejncs at narod.ru said:
> Actually I still don't understand if it is guaranteed 0 is present, or code like
> char s[VERY_LONG];
> strcpy(s, msg.data());
> s[msg.length()] = 0;
> relies on the destiny.
> Asking just out of curiosity.
"A 0MQ message is a discrete unit of data passed between applications or
components of the same application. 0MQ messages have no internal structure and
from the point of view of 0MQ itself they are considered to be opaque binary
Opaque binary data is just that. No guarantees on format, it's the
application that defines it.
Cf. also the FAQ "Does ØMQ include APIs for serializing data to/from the
wire representation?" at http://www.zeromq.org/area:faq.
In other words, if A (a C application) sends B (a C application) an ASCIIZ
string, the \0 will be there on B's end. If A' (a Python application) sends
B a Python string, the \0 will NOT be there on B's end.
If you want portable data formats you need to define one and stick to it
Pieter, I'm guessing that you're glossing over this aspect in the Guide by
"treating every message as a C string"...?
More information about the zeromq-dev