问题
I'm trying to serialize objects/messages and send them as UDP packets between nodes. I'm currently looking at cereal for serialization and boost::asio for actual network programming. Are there any examples of using these two libraries together, even if it's pseudocode?
回答1:
You can treat any example of Boost Serialization with Asio as the pseudo code example. Despite some differences, Cereal is similar enough to Boost Serialization for the samples to be relevant.
- Straight forward: sending/receiving a struct in boost::asio
- Backgrounds: Low bandwidth performance using boost::asio::ip::tcp::iostream
- More choices, raw POD data: c++ Sending struct over network
回答2:
Only use boost over the network, if your api is stable, and YOU never plan to upgrade to a newer version. Since boost serialization changes with each new release. i.e server with one version of boost and client with a another version, will not work, even if you have made no changes.
来源:https://stackoverflow.com/questions/47341936/examples-of-using-cereal-serialization-and-boostasio