On Friday, November 30, 2012 4:45:05 PM UTC-8, Robert Graham wrote:
> I am having problems where my message fails to serialize. A fatal
> exception is thrown for the
> ' ResponseMessage.SerializeToCodedStream(coded_output);'. ResponseMessage
> contains all the required fields, and is 104 bytes without the varint....
> I am compiling this for 64 bit windows, using the 32bit protoc.exe.
> // Send the response message
> // Get the byte size of the response message
> uint32_t response_message_size = ResponseMessage.ByteSize();
> // Add the varint size to the total message size
> uint32_t response_message_total_size = response_message_size
> + google::protobuf::io::CodedOutputStream::VarintSize32(response_message_size );
> boost::asio::streambuf buffer_stream;
> std::ostream output_stream(&buffer_stream);
> google::protobuf::io::ZeroCopyOutputStream* raw_output =
> new google::protobuf::io::OstreamOutputStream(&output_stream);
> google::protobuf::io::CodedOutputStream* coded_output =
> new google::protobuf::io::CodedOutputStream(raw_output);
> try
> {
> coded_output->WriteVarint32(response_message_size);
> ResponseMessage.SerializeToCodedStream(coded_output);
> delete coded_output;
> delete raw_output;
> bytes_sent = m_Socket.send(buffer_stream.data());
> }
> catch( google::protobuf::FatalException )
> {
> assert(false);
> delete raw_output;
> delete coded_output;
> bytes_sent = 0;
> }