-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 On Wed, 5 Oct 2011 02:48:39 -0700 (PDT) yorick <yorick.bru...@gmail.com> wrote:
[snip] > ---------------------------------------------------------------- > Java : > ---------------------------------------------------------------- > Socket sock; > try { > sock = new Socket("localhost", 10101); > ObjectOutputStream oos = new > ObjectOutputStream(sock.getOutputStream()); > CodedOutputStream cos = > CodedOutputStream.newInstance(oos); Why are you using an ObjectOutputStream? You're not using Java serialization for anything, so don't do that. It's probably adding headers itself which your C++ code doesn't expect. For that matter, there doesn't seem to be much reason to even create a CodedOutputStream in this case, since AbstractMessageLite.writeTo() accepts an arbitrary java.io.OutputStream, such as the one returned from sock.getOutputStream(). > > > //for(int i=0 ; i<10 ; i++){ > IRobotData data = getRobotData(); > > System.out.println("phi:"+data.getPhi()+", > distance:"+data.getDistance()); > cos.writeRawVarint32(data.getSerializedSize()); > data.writeTo(cos); > cos.flush(); > oos.flush(); Here, you're writing a Varint32 to the stream before writing the data object itself, but I don't see anything in your C++ code that reads the varint before reading the data object. Chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iEYEAREDAAYFAk6NWSoACgkQXUF6hOTGP7fW+ACffCrOhAiZ42hmX98OSbdYwIQK 1q4AniBG7I9nGOoJRnBMyop4aZ9b32AR =lmqD -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.