Examples of using cereal serialization and boost::asio?

折月煮酒 提交于 2019-12-25 12:14:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!