Boost logo

Boost Users :

Subject: [Boost-users] [asio] Error code by io_service.run(ec) not the same as in async_read_handler
From: Michael Weise (michael.weise_at_[hidden])
Date: 2016-04-06 05:58:16


Hello,

my question is about the error code returned by io_service.run_one.
I expect the error code returned by run_one to be the same as the one
in the handler - but they are not.

Inside my handler I check the error code, which is equal to operation
aborted:

void ConnectionBase::ReadUntilHandler(
    const boost::system::error_code & ec,
    std::size_t bytes_transferred)
{
   // ec == boost::asio::error::operation_aborted
   ...
}

At some other point I call io_service.run_one, which calls the above
handler:

    ...
    m_asioService.run_one(ec);
    assert(ec == boost::asio::error::operation_aborted);
    ...

The assertion fails - for some reason the error code is not the same as
in the handler.

What's the reason for this? Maybe my assumtion that run_one(ec) returns
the error code of the handler is simply wrong? If so, what error does
io_service.run(ec) actually report?

Thanks for help,
Michael

PS: boost::asio version is 1.56.0


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