On Tue, Jan 3, 2012 at 18:37, calvin zhu <[email protected]> wrote:
> client send a proto packet to server by tcp, and how do the server
> certain the packet size?
> make a packet head?

If you want to make sure that you got the whole packet, you need to
add a header with the size, yes.
A simple way is to serialize the content to a string first, determine
the size and send that size at the
very beginning. This has as well the advantage, that you can send
multiple messages, each separated with
a size-header on the same tcp connection.
This is essentially described in
  http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming

Easiest is to just send a fixed 32 bit value. A bit more fancy would
be to use a varint (
http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints
).

-h

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to