-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 You need to know how long the data will be, since Protobuf doesn’t tell you that. Your protocol somehow decides that. Either you receive up to EOF and that’s a message, or else the length of the message appears in front of the message itself. I will assume the latter case for simplicity. Once you’ve received the length indicator, you can make a char[] of the appropriate size and receive, piece by piece, the entire message into it. Once that’s done, use google::protobuf::MessageLite::ParseFromArray directly on your buffer. No need to use an std::string in this simple case.
Chris On Thu, 13 Sep 2012 08:34:54 -0700 (PDT) Murph <[email protected]> wrote: > I'm writing a c++ client/server using sockets to communicate. > > What's the best way to recv the data (over several recv calls) and > then deserialize it? Is it to recv to a char[] then copy that to a > std::string and do ParseFromString? Is there a more direct route? > > Thanks, > --Murph > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEAREDAAYFAlBUAhoACgkQXUF6hOTGP7eufgCfbh/HtbUlGUupLoj0OupBkSU/ 5akAn10VijDqkPpvvwAZfuaSgQvi2QBz =XPfc -----END PGP SIGNATURE----- -- 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.
