Search code examples
c++linux-kernelboost-asiozero-copy

How to use Zero-copy sendmsg/Receive in Boost.Asio


I am using Boost.Asio, I want to improve my system by using Zero-copy sendmsg/Receive. Can I use Zero-copy sendmsg/Receive in Boost.Asio? Could you give me how to use them if I can use them?


Solution

  • Short answer, you can only if your in-memory representation is identical to the on-the-wire one.

    See the answers here, which do an excellent job of describing how e.g. Cap'n Proto achieves this:

    Also compare:

    And on creating memory-mappable representations of advanced C++ data structures so that they can be mapped on-the-wire: