Hi, I don't see my post, so I am doing again.
I want my Java code to receiving a simple message that sent by C++ My C++: TestMsg *pbTestMsg = new TestMsg(); pbTestMsg->set_acid("7777"); pbTestMsg->set_name("Anthony"); int varIntSize = google::protobuf::io:: CodedOutputStream::VarintSize32(pbTestMsg->ByteSize()); google::protobuf::io::ArrayOutputStream arrayOut(pbBodyBuffer, (pbTestMsg->ByteSize() + varIntSize)); google::protobuf::io::CodedOutputStream coded_output(&arrayOut); coded_output.WriteVarint32(pbTestMsg->ByteSize()); pbTestMsg->SerializeToCodedStream(&coded_output); //Send 13 bytes over socket, and the header message also has the size of following. My Java: int totalBodyBytes = 13; byte[] bodyBytes = new byte[maxMessageSize]; //BufferedInputStream in bytesRead = in.read(bodyBytes, 0, totalBodyBytes); if(bytesRead == totalBodyBytes){ System.out.println("\nOK TotalBytesRead: " + bytesRead); }else{ //Not reached the block System.out.println("\n bytesReads != totalBodyBytes"); System.exit(0); } ByteArrayInputStream inStream = new ByteArrayInputStream(bodyBytes, 0, totalBodyBytes); Test.TestMsg testMsg = Test.TestMsg.parseDelimitedFrom(bodyBytes); //But here I have null testMsg. Could you guys help me out? Anthony -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.