I’m doing a program that needs send and receive data over the network. I never dealt with object serialization. I readed about some recommendations about Boost and Google Protocol Buffers. For use in Linux which is the best?
If you know some other I will appreciate your help.
Thanks.
I’ve used Boost.Serialization to serialize objects and transmit them over a socket. It’s a very flexible library, objects can be serialized intrusively if you have access to them
or non-intrusively if you don’t have access to the object you need to serialize
There are tricks to serialize Foo if it does not expose its members (
_fooand_barhere), the documentation explains this quite well. To serializeFoo, you use an object in theboost::archivenamespace: text, binary, or xml.reconstructing the archive into a Foo object is done like so
Note this example is fairly trivial, and obviously when you introduce a network you’ll be using sockets and buffers.