Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
See
http://code.google.com/intl/zh-CN/apis/protocolbuffers/docs/techniques.html#stre
aming
Streaming Multiple Messages
If you want to write multiple messages to a single file or stream, it is up to
you to keep track of where one message ends and the next begins. The Protocol
Buffer wire format is not self-delimiting, so protocol buffer parsers cannot
determine where a message ends on their own. The easiest way to solve this
problem is to write the size of each message before you write the message
itself. When you read the messages back in, you read the size, then read the
bytes into a separate buffer, then parse from that buffer. (If you want to
avoid copying bytes to a separate buffer, check out the CodedInputStream class
(in both C++ and Java) which can be told to limit reads to a certain number of
bytes.)
Original comment by pop.atry@gmail.com
on 3 Dec 2010 at 4:05
Original issue reported on code.google.com by
jbdraw...@gmail.com
on 2 Dec 2010 at 11:12