I am using 'protobuf' for C/S network program using TCP.
here is my steps for client:
1, pack data into a 'protobuf'
2, get size in bytes of the pack and construct a length-prefix frame
3, write the frame+pack to socket
and then the server:
1, read Length-prefix frame from socket and get the length N
2, read N bytes from socket and fill the data into protobuf instance
3, get "value"s from protobuf by "key"s
it seems a little complicated I think, is there some kind of auto-generated length-prefix frame for protobuf, then I do not need construct one by myself. or anything else I can do to make code cleaner?