On Jul 10, 2010, at 7:47 , Maxim Leonovich wrote:
ArrayOutputStream(buffer,msg.ByteSize() + 4,sizeof(char));

The documentation states:

block_size is mainly useful for testing; in production you would probably never want to set it.

So you should get rid of the "sizeof(char)" part.

cos->WriteLittleEndian32(msg.ByteSize()); //Tryed "WriteVariant32", didn't help

If you want to use Java's .parseDelimitedFrom, you *must* use WriteVarint32, because that is the format it expects the length prefix. In this case, you'll need to call ArrayOutputStream:: ByteCount() to figure out how many bytes were actually serialized.

You also probably should create the ArrayOutputStream and CodedOutputStream on the stack, rather than using new. This will be slightly faster.

That said, the only issue here that affects correctness is the WriteVarint32 part. The rest shouldn't matter unless I missed something. You should change your code to do that, then if you are still having problems you should try dumping the contents of the buffer on both the C++ and the Java side. Maybe the input/output is getting messed up somewhere?

Good luck,


Evan Jones

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to