Re: [protobuf] Re: Protocol Buffers and asynchronous sockets

2009-11-24 Thread Kenton Varda
Yes, use std::string. The only potential problem is if your messages are very large -- allocating large contiguous blocks of memory (as std::string does) could lead to memory fragmentation. But for small and medium-sized messages, there's no reason not to use std::string as the buffer. Parsing f

Re: [protobuf] Re: Protocol Buffers and asynchronous sockets

2009-11-24 Thread Evan Jones
Gilad Ben-Ami wrote: > Do you think that using std::iostream in the following scenario would > work / be a good choice? > 1. read message_length > 2. buffer message_length bytes into iostream variable. > 3. when all data is received, use IstreamInputStream to wrap the > iostream and have it parsed

[protobuf] Re: Protocol Buffers and asynchronous sockets

2009-11-24 Thread Gilad Ben-Ami
Thanks for the suggestion. Do you think that using std::iostream in the following scenario would work / be a good choice? 1. read message_length 2. buffer message_length bytes into iostream variable. 3. when all data is received, use IstreamInputStream to wrap the iostream and have it parsed with

Re: [protobuf] Re: Protocol Buffers and asynchronous sockets

2009-11-24 Thread Evan Jones
Gilad Ben-Ami wrote: > 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? To use protocol buffers with an asynchronous library, you need to collect the data for the message is some data structure unti

[protobuf] Re: Protocol Buffers and asynchronous sockets

2009-11-24 Thread Gilad Ben-Ami
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 ParseFromAr