Protocol buffers implement their own serialization routines: the writeTo(OutputStream output) method will write the binary format to the OutputStream. From a socket, just do:
MyProtoBuf pb = new MyProtoBuf; ... pb.writeTo(socket.getOutputStream()); On Wed, Dec 2, 2009 at 7:47 AM, Nigel Pickard <pickard.ni...@gmail.com>wrote: > OK, so far I like GPB. However, I have a very simple question, but > one which I can't find an answer for: > > I have created a test Java application that uses ObjectInputStream and > ObjectOutputStream over sockets. No problems, it works! I use my GPB > class writeTo and parseFrom to send and reconstitute my GPB class > using the ObjectInput and Output Streams.... > > But: isn't GPB allowing for serialization using bytes? Are Object I/O > Streams the best streams to use? Should I be using something else > like Data I/O streams? E.g. from JavaDocs, "An ObjectOutputStream > writes primitive data types and graphs of Java objects to an > OutputStream" -is there a better, more efficient I/O stream I should > be using? > > My concern is that when it comes to attempting to open a socket to a C+ > + app, I assume the correct I/O stream type should be used. > > If anyone has a working example of best practice using Data I/O > streams or a recommended stream type, that would be extremely useful > for me (even better if someone has a simple Java to C++ using sockets > example). > > Thanks. > > -- > > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@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.