Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 240
masshuroom Avatar asked Nov 21 '25 20:11

masshuroom


1 Answers

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:

  • Do cereal and Boost Serialization use zero-copy?

Also compare:

  • TCP Zero copy using boost

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

  • https://www.boost.org/doc/libs/1_72_0/doc/html/interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.making_ipc_easy.managed_memory_segments_intro, specifically about basic_managed_heap_memory and basic_managed_external_buffer

  • I have a gazillion examples on this site which show how to use such managed memory segments, but usually focused on managed_mapped_file and managed_shared_memory which have the exact same feature set, so you can use these with the previous managed heap segments in the same way: https://stackoverflow.com/search?q=user%3A85371+interprocess+allocator

like image 141
sehe Avatar answered Nov 24 '25 10:11

sehe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!