Hello All;

New to protobuf and did some limited search for my question. So my
apology if this has already been talked about.

I naively thought that ParseFromFileDescriptor/ParseFromIstream would
block on an TCP socket and return when a valid message is received.
Read some old posts from 2010 and realized it's not that easy due to
mesages not being self-delimiting.  And the suggestion from Jason
Hsueh was as follows:
"
One approach to writing multiple messages to the same stream is to use
a
length-delimited format: write the size of the message, then serialize
the
message itself. On the receiver side, you would set up a
FileInputStream,
and wrap a CodedInputStream around that. You can read the size of the
messages from the stream and then use PushLimit and PopLimit to
control how
much data is read.
"

My quesions are:

1. Is this still the way to do it? Seems quite cumbersome (to lazy
me ;-).  Is there  a wrapper built in to do this?
2. If I understand Jason's suggestion riht, the length is really not
part of the message, and the sender has to explcitly set it, instead
of having protobuf encode it in. Which means a generic third party
sender using my .proto file would not be sufficient.  Plus how would
they know the length before encoding the message proper? Filling it in
after the fact would change the length again?     or I am totally
missing it.

3. A related quesiton is in general do I have to manage reading of the
socket, or for that matter any istream, and spoon feed the protobuf
parser until it says OK, that's a whole message?

Thanks a lot.

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

Reply via email to