It's a good idea to send a delimiter as well, even if your end-to-end communication is considered reliable (TCP). A software bug at ether end could cause you to loose sync.
Use one byte as your "Start Byte" (0xaa for example) followed by the length of your message (can be a compressed integer). When you receive a message, look for the Start byte (which should always be the first byte), decode the length, and then verify that you have all the bytes you need to decode the rest of the data. Before you decode, verify that you have reached the end of the stream or that the next byte is the start of the next message. Kenton Varda wrote: > Send the size of the message first, then the data. > > On Mon, Jan 12, 2009 at 4:34 PM, chongyc <[email protected] > <mailto:[email protected]>> wrote: > > > When I send multiple messages, I should delimit them, and parse the > buffer. > > What is the best way delimitting it that you can recommend me ? > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---
