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

> 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
> (;
> metaMessageBuilder.setType(MessageType.ADD_FILE);
> CodedOutputStream out = CodedOutputStream.newInstance
> (socket.getOutputStream());
> 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
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to