How to use protocol buffers?

You start by defining your message in a . Proto file.

You start by defining your message in a . Proto file: package foo; message snd_data { required string var= 1; required int32 var1 = 2; optional float var2 = 3; optional double var3 = 4; } (I guess the float and double actually are different variables...) Then you compile it using protoc and then you have code implementing your buffer. For further information see: code.google.com/apis/protocolbuffers/doc....

Thanks for reply. Is there any simple tutorial where an example is shown? Thanks again, – make Dec 2 '09 at 17:56 Follow the link I included - it's a tutorial that covers using protocol buffers from C++.

– Douglas Leeder Dec 2 '09 at 23:36.

Protobufs is not endian-sensitive itself, but neither does protobufs define a transport mechanism -- protobuf defines a mapping between a message and its serialized form (which is a sequence of (8-bit) bytes) and it is your responsibility to transfer this sequence of bytes to the remote host. In our case, we define a very simple transport protocol; first we write the message size as an 32-bit integer (big endian), then comes the message itself.(Also remember that protobuf messages are not self-identifying, which means that you need to know which message you are sending. This is typically managed by having a wrapper message containing optional fields for all messages you want to send.

See the protobuf website and mailing list archives for more info about this technique. ).

Otherwise you need to watch for big endian and little endian differences. Its also worth paying attention to struct packing. Passing pointer can be problematic too due to the fact pointer are different sizes on different platforms.

All in there is far too little information in your post to say, for certain, what is going wrong ...

The machines are different. Unix isinstalled on sun-blade and windows on x86. But, I read that protocol buffers deal with different machines and this is why I decided to use it... – make Dec 2 '09 at 17:54.

The answer lies in the endianess of the data being transmitted, this is something you need to consider very carefully and check. Look here to show what endianness can do and cause data to get messed up on both the receiver and sender. There is no such perfect measure of transferring data smoothly, just because data sent from a unix box guarantees the data on the windows box will be in the same order in terms of memory structure for the data.

Also the padding of the structure on the unix box will be different to the padding on the windows box, it boils down to how the command line switches are used, think structure alignment. Hope this helps, Best regards, Tom.

Googling for protocol buffers and endian shows a Google Groups conversation that indicates that the software handles this correctly: groups.google. Com/group/protobuf/browse_thread/thread/… – quamrana Dec 2 '09 at 22:04 @quamrana: I cannot answer that as I do not know google' protocol buffers, sorry there on that one. Check your structure padding, the compiler could be padding it out to make it an even size.

You can check that by doing a sizeof(struct snd_data) on both ends to see what it is? If you get different sizes than that could go some way to explaining your situation. – t0mm13b Dec 2 '09 at 22:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions