> 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?

Protocol buffer code doesn't use object streams, so when you pass one
to its writeTo/parseFrom methods, you're actually passing the object
stream as a regular OutputStream or InputStream, ie, your code is
already serializing to and from bytes.  If you'd rather be explicit
about it, you can just switch your stream's type from
ObjectOutputStream to OutputStream (similarly with Input) and it
should continue to work the same.  All that should require is instead
of doing something like

ObjectOutputStream output = new ObjectOutputStream(socket.getOutputStream());
message.writeTo(output);

you do something like

OutputStream output = socket.getOutputStream();
message.writeTo(output);

For interacting with C++, you should be able to use the standard C++
API for reading in messages, since the data is already on the wire in
byte format.

- Adam

--

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.


Reply via email to