Hey, The protocol we've defined for this kind of solution is to send a fixed 4 byte unsigned interger that represents the following PB message length, read the PB message and wait again for the size.
So in this case, what is the best method to use PB? Should i use SerializeToArray and ParseFromArray instead of using the protobuf::io streams? (because the data I'm buffering is stored in a char* array) Does PB provide any stream i can feed with data until I've read all the expected bytes and then order to parse? Thanks. On Nov 24, 12:56 pm, Mika Raento <[email protected]> wrote: > Protobufs are pretty much designed to be read all at once. The normal > thing would be to define a stream format that prefixes the serialized > protobufs with their length and buffer the data until a whole protobuf > has been read. > > In other words: you should not describe the whole stream as a single > protobuf (like you often would with, say, XML) but instead use a > different format for framing a stream of protobufs. > > Regards, > Mika > > 2009/11/24 Gilad Ben-Ami <[email protected]>: > > > Hey, > > > I'm using ACE library for C++ and it's reactor pattern for handling > > asynchronous read from / write to sockets. > > I'm trying to integrate Protocol buffers into my solution in order to > > exchange data with another process developed in Java. > > > The way asynchronous work, forces me to know in advance what is the > > expected message size and only after i have all the data try to parse > > it with PB. > > What is the best way to use PB in this scenario? Is there any Stream i > > can use to hold the data arrived? and i can i recover from trying to > > parse a message that has failed because of not enough data arrived? > > > Your help is appreciated. > > Thanks. > > > -- > > > 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 > > athttp://groups.google.com/group/protobuf?hl=en. -- 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.
