Looking for an idea to implement a network application with protobuf

2,602 views
Skip to first unread message

Trustin Lee

unread,
Dec 17, 2008, 7:19:29 AM12/17/08
to Protocol Buffers
Hi,

I'm currently trying to write a prototype client / server application
that exchanges a message which is encoded with protobuf format. From
my understanding, it seems like a user usually defines a top level
message type that can be a container of other messages. This approach
is called 'extension', and is described here in detail:

* Official documentation - http://tinyurl.com/56cerv
* Forum discussion - http://tinyurl.com/5zabns

The question is, is this the most common and efficient way to exchange
various types of messages with protobuf? What did you do to build a
network application with many complex message types? Is there any
alternative approach that might be used in a certain case? I'd like
to hear your experience.

Thanks,
Trustin

Stuart Johnson

unread,
Dec 17, 2008, 7:43:51 AM12/17/08
to prot...@googlegroups.com

>
> The question is, is this the most common and efficient way to exchange
> various types of messages with protobuf?


Its very efficient, whilst keeping flexibility. To stream it, I add 3+
bytes.

Start byte
Length byte(s)
ProtoWrapper (which includes message type enumerator)
ProtoMessage
End byte

Once the Length byte is read, I verify that the end byte is where it
should be before deserialising (just in case the client is sending buggy
messages, and you loose sync).

All my message types are defind in a large enumerator. I'm hoping one
day the protobuf compiler will build that for me.

Stuart.


Reply all
Reply to author
Forward
0 new messages