I want to do asynchronous read from cin therefore I have a piece of code
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, '
',
boost::bind(&Client::handle_std_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
The problem is: when I run my client the normal way [ ./client ] and then input something via command like, it works like charm. However, when I run it via [ ./client < test ] it throws :
terminate called after throwing an instance of 'boost::exception_detail::clone_impl
' what(): assign: Operation not permitted Aborted
Do you have an idea of what the problem might be? Thanks!
See Question&Answers more detail:os