【发布时间】:2014-05-12 16:35:16
【问题描述】:
我想从 cin 进行异步读取,因此我有一段代码
client.h
...
boost::asio::posix::stream_descriptor input;
boost::asio::streambuf input_buffer
client.cpp
Client::Client(int argc, char **argv, boost::asio::io_service &io_service)
: tcp_socket(io_service)
, udp_socket(io_service)
, input(io_service, ::dup(STDIN_FILENO))
{
...
read_std_input();
}
void Client::read_std_input() {
async_read_until(input, input_buffer, '\n',
boost::bind(&Client::handle_std_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
问题是:当我以正常方式 [ ./client ] 运行我的客户端,然后通过类似命令输入一些内容时,它就像魅力一样工作。 但是,当我通过 [ ./client
在抛出一个实例后调用终止 'boost::exception_detail::clone_impl
'what():assign: Operation not allowed Aborted
您知道问题可能是什么吗? 谢谢!
【问题讨论】:
-
你没有提到你使用的是什么平台。 Windows 和 Linux(以及 ....)对异步文件 I/O 的支持大不相同
-
我使用的是 linux mint 16 64bit
-
用 strace 看看系统调用可能会抱怨什么。
-
你能提供你的内核配置吗?例如。 “启用 AIO 支持 (AIO)”等会很有趣
标签: c++ boost boost-asio