Re: [protobuf] How to determine if the input is malformed? (C++, MessageLite::ParseFromCodedStream)

142 views
Skip to first unread message

Christopher Head

unread,
Sep 12, 2012, 2:38:22 PM9/12/12
to prot...@googlegroups.com

Protobuf messages do not have inherent delimiters; in fact, the concatenation of two messages can sometimes be a perfectly valid single message. Add delimiters in your protocol (if you are only sending a single message then just shutdown() the socket afterwards and have the recipient read until EOF; otherwise, send the length of the message in front of the message itself).

Chris

On Sep 12, 2012 8:37 AM, "iz" <izf...@gmail.com> wrote:

iz

unread,
Sep 13, 2012, 3:02:52 AM9/13/12
to prot...@googlegroups.com
Thanks, Chris! I understood. Using the message length is the only simple solution for this issue.

среда, 12 сентября 2012 г., 22:38:25 UTC+4 пользователь Christopher Head написал:
Reply all
Reply to author
Forward
0 new messages