TCP使用boost的零拷贝 [英] TCP Zero copy using boost

查看:469
本文介绍了TCP使用boost的零拷贝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用boost实现tcp零拷贝,但我不能在google上找到任何东西。我的问题是可能执行零拷贝使用boost库,如果是这样请
给我一些例子或一些链接。

I am trying to implement tcp zero copy using boost but i am not able to find anything on google .My question is it possible to perform zero copy using boost libraries and if so please send me some example or some link.

推荐答案

您可以观看Yandex家伙的BoostCon演讲: 基于Boost.Asio的网络服务器的优化

You could watch this BoostCon talk by the Yandex guys: The Optimization of a Boost.Asio-based Networking Server

我的直觉感到说他们(Yandex的家伙)overengineine这个(相当多...)。我会说,基本的解决方案将在于使用预先分配的固定缓冲区(也许每线程),并使用MutioBufferSequence概念从Asio将它们粘合在一起。

My gut feeling says they (the Yandex guys) overengineered this (quite a bit...). I'd say the essential solution would lie in just using pre-allocated fixed-buffers (perhaps per-thread) and use the MutableBufferSequence concept from Asio to glue them together.

此方法称为 Scatter-Gather a> ,并且仅在Asio文档中进行简要说明。这里可能有一个相关示例: http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio/examples/cpp11_examples.html#boost_asio.examples.cpp11_examples.buffers

As @Nim已经注释过,Asio默认工作在零拷贝模式(因为它从来不拥有一个缓冲区,也不代表调用者分配)。所以它应该是很简单的让它工作。当然,内核/ libc函数是否以零拷贝方式实现仅取决于操作系统/平台。

As @Nim already commented, Asio by default works in "zero-copy" mode (because it never owns a buffer, nor allocates on behalf of the caller). So it should actually be pretty simple to get it to work. Of course, whether the kernel/libc functions are implemented in zero-copy fashion depends solely on the OS/platform.

这篇关于TCP使用boost的零拷贝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆