asio

boost:asio::read or boost:asio::async_read with timeout

百般思念 提交于 2019-12-02 18:05:54
问题 Yes. I know there have been a few questions around this time_out in boost::asio . My problem might to too simple for the asio guys to solve here. I am using boost::asio on TCP protocol to read data over a network continuously in a loop as fast as I can. Following function ReadData() gets called continuously from a worker std::thread in a while loop. std::size_t ReadData(std::vector<unsigned char> & buffer, unsigned int size_to_read) { boost::system::error_code error_code; buffer.resize(size

boost:asio::read or boost:asio::async_read with timeout

做~自己de王妃 提交于 2019-12-02 09:38:00
Yes. I know there have been a few questions around this time_out in boost::asio . My problem might to too simple for the asio guys to solve here. I am using boost::asio on TCP protocol to read data over a network continuously in a loop as fast as I can. Following function ReadData() gets called continuously from a worker std::thread in a while loop. std::size_t ReadData(std::vector<unsigned char> & buffer, unsigned int size_to_read) { boost::system::error_code error_code; buffer.resize(size_to_read); // Receive body std::size_t bytes_read = boost::asio::read(*m_socket, boost::asio::buffer

BOOST.ASIO源码剖析(一)

久未见 提交于 2019-11-30 20:53:34
前言 源码之前,了无秘密。 ——侯捷 Boost库是一个可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一。Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,是不折不扣的“准”标准库。 boost.asio是Boost库中非常著名的I/O组件,是用于网络和低层IO编程的跨平台C++库,为开发者提供了C++环境下稳定的异步模型。其在性能、移植性、扩展性等方面均为人称道,甚至被很多业内人士称为“网络神器”。asio是目前唯一有希望进入C++标准库以弥补标准库在网络方面的缺失的C++网络库,因此对asio的学习在某种意义上可以说是学习C++网络编程的必修课。 当前网络上从用户角度介绍asio的文献很多也很完善,所以本文决定另辟蹊径,从asio源码角度出发,由内而外、深入浅出地剖析asio的架构和设计理念,将asio的一切秘密呈现在读者眼前。 本文适合已有较完善的C++基础知识、具备一定程度的泛型技术和面向对象技术、并对boost.asio有一定的了解的读者。 首先,本文先从面向对象的角度对asio的架构开始剖析,由粗至细。先让读者对asio有一个高屋建瓴的认识,再逐步细化,最终透彻地了解asio的架构。 然后,本文以Windows平台下的Tcp协议为例,以跟踪流程的方式探究asio的运作原理。

Boost.Asio技术文档

烈酒焚心 提交于 2019-11-29 16:56:41
Christopher Kohlhoff Copyright © 2003-2012 Christopher M. Kohlhoff 以Boost1.0 的软件授权进行发布(见附带的LICENSE_1_0.txt文件或从 http://www.boost.org/LICENSE_1_0.txt ) Boost.Asio 是用于网络和低层IO 编程的跨平台C++库,为开发者提供了C++环境下稳定的异步模型. 综述 基本原理 应用程序与外界交互的方式有很多, 可通过文件,网络,串口或控制台.例如在网络通信中,完成独立的IO操作需要很长时间.对应用程序开发者提出了一个挑战. Boost.Asio 提供了管理需长时间运行操作的工具, 但不必涉及到线程的并发模式和显式锁定. Boost.Asio 库使用C++ 来实现,提供如网络编程等常用的操作系统接口. Boost.Asio实现了如下目标: · 可移植性Portability. 库支持一系列的常用系统操作, 具有稳定的跨平台特性. · 可扩展性Scalability. 库可以帮助开发者构建数千并发连接的网络应用程序.asio 库实现的每个系统操作都使用了最具扩展性的机制. · 效率Efficiency. 库支持发散聚合IO(scatter-gather I/O) 等技术,使应用程序尽量少的拷贝数据. · 可以像BSD Sockets

NAudio Asio Record and Playback

谁都会走 提交于 2019-11-29 16:26:06
I'm trying to write my own VST Host and for that i need to record and play audio from an Asio Driver (in my case for an audio interface). That's why i'm trying to use NAudio's AsioOut. For testing purposes i'm currently just trying to record the input, copy and play it to the output. My code looks like this: var asioout = new AsioOut(); BufferedWaveProvider wavprov = new BufferedWaveProvider(new WaveFormat(44100, 2)); asioout.AudioAvailable += new EventHandler<AsioAudioAvailableEventArgs>(asio_DataAvailable); asioout.InitRecordAndPlayback(wavprov, 2, 25); asioout.Play(); ... void asio

How to set error_code to asio::yield_context

若如初见. 提交于 2019-11-28 11:44:47
I'd like to create an asynchronous function which takes as it's last argument boost::asio::yield_context. E.g.: int async_meaning_of_life(asio::yield_context yield); I'd also like to be consistent with how Asio returns error codes. That is, if the user does: int result = async_meaning_of_life(yield); and the function fails, then it throws the system_error exception. But if the user does: boost::error_code ec; int result = async_meaning_of_life(yield[ec]); Then - instead of throwing - the error is returned in ec . The problem is that when implementing the function, I can't seem to find a clean

NAudio Asio Record and Playback

喜你入骨 提交于 2019-11-28 11:33:46
问题 I'm trying to write my own VST Host and for that i need to record and play audio from an Asio Driver (in my case for an audio interface). That's why i'm trying to use NAudio's AsioOut. For testing purposes i'm currently just trying to record the input, copy and play it to the output. My code looks like this: var asioout = new AsioOut(); BufferedWaveProvider wavprov = new BufferedWaveProvider(new WaveFormat(44100, 2)); asioout.AudioAvailable += new EventHandler<AsioAudioAvailableEventArgs>

How to record and playback with NAudio using AsioOut

十年热恋 提交于 2019-11-28 00:36:43
I'm trying to get the sound input and send output directly with less latency possible with C#. I'm using the library NAudio that supports ASIO for better latency. In particular, I use the AsioOut object for recording and another for playback initialized with a BufferedWaveProvider , which is filled in a Callback function: OnAudioAvailable , which allows me to use the ASIO buffers. The problem is that I hear the sound with various glitches and with a bit of delay . I think the problem is in the function OnAudioAvailable where the buffer is filled with data taken as input from the sound card.