Suppose I accept a socket by calling async_accept like this
acceptor.async_accept([](const boost::system::error_code& ec, boost::asio::ip::tcp::socket sock)
{
if (ec)
return;
auto sess = std::make_shared<session>(std::move(sock));
sess->start_reading();
//...
});
My question is, in what cases can sock.is_open() return false (inside session)? I know that if, for example, I call sock.close() (or move socket object), then is_open will return false. But are there other situations in which is_open can return false? If so, under what circumstances?
For example, maybe when calling io_context::stop() or under other circumstances?
sessionobject will be destroyed because the asynchronous read operation will be canceled (start_reading). My question was in the context ofsessionremaining active, which means this is not the case.io_context::stop()will not do anything to individual IO objects (it would violate the thread safety guarantee, if anything)