|
|
От: |
Evgeny.Panasyuk
|
|
| Дата: | 02.11.16 12:19 | ||
| Оценка: | +1 | ||
boost::asio::spawn(my_strand, do_echo);
// ...
void do_echo(boost::asio::yield_context yield)
{
try
{
char data[128];
for (;;)
{
std::size_t length =
my_socket.async_read_some(
boost::asio::buffer(data), yield);
boost::asio::async_write(my_socket,
boost::asio::buffer(data, length), yield);
}
}
catch (std::exception& e)
{
// ...
}
}If the asynchronous operation fails, the error_code is converted into a system_error exception and thrown.