Use ParseFromCodedStream() rather than MergeFromCodedStream().
Read and write the size of each protocol buffer message.