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

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

问题描述

我想使用boost实现TCP零拷贝,但我无法找到谷歌。我的问题是什么有可能使用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的家伙)过度设计这个(相当多的...)。我想说的基本的解决办法在于仅仅使用pre分配固定的缓冲区(也许每个线程),并使用从短耳的MutableBufferSequence概念粘合在一起。

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.

这方法被称为 <一个href=\"http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio/overview/core/buffers.html\">Scatter-Gather并且仅短暂地在短耳文档说明。有可能是这里一个相关的例子:<一href=\"http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio/examples/cpp11_examples.html#boost_asio.examples.cpp11_examples.buffers\">http://www.boost.org/doc/libs/1_56_0/doc/html/boost_asio/examples/cpp11_examples.html#boost_asio.examples.cpp11_examples.buffers

由于@Nim已经处于零拷贝模式评论,短耳默认情况下工作(因为它永远不会拥有一个缓冲区,也不会分配代表调用者)。因此,它实际上应该是pretty简单的得到它的工作。当然,无论内核/ libc函数中实现零拷贝的方式完全取决于OS /平台上。

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天全站免登陆