[protobuf] Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
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

Re: [protobuf] Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Adam Vartanian
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

[protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
Thanks for the reply Adam -I did a simple sub into my code with your suggestion, but it doesn't work. However, now it's made me think of more questions. If protocol buffers doesn't use object I/O streams, which streams does it use? The argument in Java simply asks for an OutputStream

Re: [protobuf] Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Jason Hsueh
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

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Kenton Varda
Well ok, using gzip streams would obviously give you something different (the bytes would come out gzipped). But none of the stream types you listed make a difference. On Wed, Dec 2, 2009 at 12:25 PM, Kenton Varda ken...@google.com wrote: It doesn't matter what kind of stream you use.

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Adam Vartanian
If protocol buffers doesn't use object I/O streams, which streams does it use?  The argument in Java simply asks for an OutputStream argument, and of course that could mean File, ByteArray, Object, Data, etc I mean that it only depends on the methods in OutputStream. You can provide

[protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
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

[protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
Aaaah I think the fog is lifting. thanks! So am I correct in thinking that byte order is taken in to account by the GPB writeTo and parseFrom methods, no matter whether it's Java, C+ +, etc? On Dec 2, 3:25 pm, Kenton Varda ken...@google.com wrote: It doesn't matter what kind of stream you

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Henner Zeller
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?

[protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
Adam, Jason, Kenton and Henner, thanks and much appreciated! -- 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] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
Oh, wait So I have a test Java app where one thread is running as a server, one as a client. I've been sending a GPB defined class instance between them, no problem when I use Object I/O streams (e.g. ObjectOutputStream on the server, ObjectInputStream on the client. I've been calling

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Henner Zeller
Are your ObjectOutputStreams transparent ? Or do they prepend/append things to the data ? On Wed, Dec 2, 2009 at 13:11, Nigel Pickard pickard.ni...@gmail.com wrote: Oh, wait So I have a test Java app where one thread is running as a server, one as a client. I've been sending a GPB defined

[protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Nigel Pickard
Henner: I'm not sure what you mean by the datastream being transparent, but basically I'm sending a GPB instance from the server to the client. Initially I used ObjectOutputStream on the server, ObjectInputStream on the client. I then changed the client to use DataInputStream (apologies, my

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Henner Zeller
Hi, On Wed, Dec 2, 2009 at 15:21, Nigel Pickard pickard.ni...@gmail.com wrote: Henner: I'm not sure what you mean by the datastream being transparent, but basically I'm sending a GPB instance from the server to the client. Initially I used ObjectOutputStream on the server, ObjectInputStream

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Kenton Varda
There is no reason to use ObjectInputStream/ObjectOutputStream with protocol buffers. On Wed, Dec 2, 2009 at 4:15 PM, Nigel Pickard pickard.ni...@gmail.comwrote: When the Java test app works, I'd say the IO stream is transparent. I use the same simple object instance each time (have a hard

Re: [protobuf] Re: Java -using GPB -which type of stream should I be using over sockets?

2009-12-02 Thread Jason Hsueh
On Wed, Dec 2, 2009 at 4:15 PM, Nigel Pickard pickard.ni...@gmail.comwrote: When the Java test app works, I'd say the IO stream is transparent. I use the same simple object instance each time (have a hard coded method that simply returns the same object so it's identical), and I simply call