hi, 

I am trying to transfer a C structure, say "struct stat"  over the wire via 
protobuf and ran into a strange issue. I define the message as:

message FileStat {
   optional bytes  stat = 1;
   ...
}

On the sender side, I fill in the data as the following (with C++ interface)

FileStat fs;
struct stat  st = {};  // fill in data properly
fs.set_stat(&st, sizeof(struct stat));   // set the stat value

On the receiving end, I first verified the total message size matches what 
I am expecting, then, I want to recover this structure from the "bytes" 
field. However, first I want to check the exact size of this field, aka. 
"stat".

so I print "fs.stat().size()" 

I see this fs.stat() is defined as const string &, and suprisingly, the 
size print out is ZERO.

I am assuming there will be "\0" in the buffer, so this should not be 
treated as a regular C-string. However, in the case of "bytes" field, how 
do I probably get the data out and cast it properly?

I tried direct casting, and it doesn't seem to get it correct:

 
thanks for help.

Oliver





-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to