I'm using boost::asio, version boost is 1.71. Initially i have ip::tcp::socket object, name it "socket". I need to get the io_context, used by this socket.
In early boost versions (1.62, for example) it was simple. There was asio::basic_socket::get_io_service() method. But how can i do it in boost 1.71?
This necessity appeared since i have a project that intensively uses boost1.62 and "asio::basic_socket::get_io_service()" used ubiquitously.
I have tried:
// сокет socket
asio::executor e = socket.get_executor();
asio::execution_context &e_context = e.context();
asio::io_context &context_instance = static_cast<asio::io_context&>(e_context);
But it looks dangerous and incorrect. Though it build and run successful.