Echo AsyncReadStream/AsyncWriteStream example
(too old to reply)
Adam Zegelin
2016-12-30 08:46:31 UTC

Is there a boost::asio example that shows an implementation of
AsyncReadStream/AsyncWriteStream that copies write->read? i.e. echoes
what was sent

I’m trying to emulate serial device that takes input commands
separated by \r, executes them, and then outputs the result.
i.e., I'm trying to create a fake asio::serial_port that can read
input, process it and then provide output.

The device I'm trying to emulate echoes the sent characters. Commands
are executed once '\r' is received. Ideally the fake serial port also
echos the received data immediately.

I've got the read part working by implementing async_write_some(…),
but I'm having trouble implementing the async_read_some(…) method so
that it can be called at anytime, especially when io_service.run() is
run from multiple threads.