Boost logo

Boost Users :

Subject: [Boost-users] Echo AsyncReadStream/AsyncWriteStream example
From: Adam Zegelin (adam_at_[hidden])
Date: 2016-12-30 03:46:31


Hi.

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.

Thanks,
Adam


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net