You may want to consider the techniques described in the protobuf doc
under Techniques/Union Types here:

By using an enum/extensions, you can use protobuf for the header as
well as the payload.  The wrapper message would represent the channel
number as enum or the extension field identifier.  The advantages:

* You can harness protobuf's forward/backward compatibility tricks to
modify the header
* You can easily use varint encoding for the channel number


On Nov 17, 12:00 pm, "Ivarsson, Magnus"
> Hi, we are assuming that the tcp connection gets us in sync so we
> skipped the start bit.
> On the other hand we needed to distinguish different channels (to be
> able to send several proto api:s to the same port) so our header looks
> like this:
> 1 byte 0x00 (to be used for version information if we change the header
> later on)
> 2 bytes in network byte order for the channel number
> 2 bytes in network byte order for the length
> The channel will probably raise a few eyebrows - the tcp port could do
> the job.. However when we go for ssl encryption and embedded devices I
> think one session should be enough.
> Please give us feedback if you don't (or do) like the solution.
> /Magnus
> -----Original Message-----
> From: [mailto:[EMAIL PROTECTED] On
> Behalf Of Stuart
> Sent: den 17 november 2008 16:23
> To: Protocol Buffers
> Subject: Streaming
> I have a c# server application with miltiple clients.  I want to
> replace the existing protocol with PB.
> The clients connect, and remain connected prediodically passing data
> of differnet types.
> I have searched the discusstion group, and found a few postings
> relating to this issue, but nothing final, so before I start writing
> my own solution, I was wondering if anyone had any ideas?
> I'm thinking about doing something simple, like this:
> <byte> StartByte (constat value)
> <byte[]>Length of payload (compressed integer)
> <byte[]>PB data
> <byte> EndByte (constat value)
> To decode:
> while(true)
> {
>      Look for StartByte
>      Grab Length integer
>      If EndByte is where it is expected
> : Decode
> }
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 [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to