Ok, I can do that. But that comes accross as a twisted way of doing things, especially when both ends know the message format and should know when its end has been reached... Is there any solution that is a bit more elegant?
On Mar 12, 10:12 pm, Kenton Varda <ken...@google.com> wrote: > parseFrom() reads and parses the entire stream, so it won't stop reading > until it reaches EOF. If you don't want to close the socket on the sending > end, then you should write the size of the message first, then the contents. > Then, on the receiving end, you'll need to read that size first, then use > PushLimit() on your CodedInputStream to make sure it doesn't read more than > that many bytes. > > On Thu, Mar 12, 2009 at 3:58 AM, marc-andre > <marcandre.laverdi...@gmail.com>wrote: > > > > > Hello all, > > > This is my first time using PB, and I'm already stuck. On something > > that should be simple too... Oy! > > > Essentially, I send a message within a wrapper that indicates the > > message type. From what I saw on the forums, that's the common > > practice. I'm able to create the message, but nothing gets read on the > > other side. > > > What am I doing wrong? > > > Client side: > > a.AddProtectedFileRequest.Builder addfileMessageBuilder = > > a.AddProtectedFileRequest.newBuilder(); > > addfileMessageBuilder.setA(a); > > addfileMessageBuilder.setB(b); > > a.MetaMessage.Builder metaMessageBuilder = a.MetaMessage.newBuilder(); > > metaMessageBuilder.setAddProtectedFileRequest > > (addfileMessageBuilder.build()); > > metaMessageBuilder.setType(MessageType.ADD_FILE); > > CodedOutputStream out = CodedOutputStream.newInstance > > (socket.getOutputStream()); > > metaMessageBuilder.build().writeTo(out); > > out.flush(); > > > Server Side: > > MetaMessage read = a.MetaMessage.parseFrom(CodedInputStream.newInstance > > (stream)); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---