On Wed, Dec 2, 2009 at 12:31, Nigel Pickard <pickard.ni...@gmail.com> wrote:
> Jason -do you mean any Java output stream type will work (as all Java
> IO stream types ultimately use bytes), and that the byte stream
> produced will have the bytes put in an accepted standard order by the
> writeTo method?  In other words, using the writeTo method for *any*
> Java output stream type will produce a series of bytes that will
> *always* be able to be read using the C++ equivalent of parseFrom on
> the C++ side?

Yes. Protocol Buffers are designed to be platform and language
independent so given a transparent way to transport raw bytes (any
output stream), serialization and deserialization between any
combination works as you expect. Since you asked: raw types such as
integers are serialized in a proto buffer specific way with a
consistent byte order independent of the platform.

-h

>
>
> On Dec 2, 1:20 pm, Jason Hsueh <jas...@google.com> wrote:
>> 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.
>
>
>

--

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