diff --git a/include/async_web_server_cpp/http_connection.hpp b/include/async_web_server_cpp/http_connection.hpp index b1cbf6d..a7677c2 100644 --- a/include/async_web_server_cpp/http_connection.hpp +++ b/include/async_web_server_cpp/http_connection.hpp @@ -79,7 +79,7 @@ class HttpConnection : public boost::enable_shared_from_this, void handle_write(const boost::system::error_code& e, std::vector resources); - boost::asio::io_context::strand strand_; + boost::asio::strand strand_; boost::asio::ip::tcp::socket socket_; HttpServerRequestHandler request_handler_; boost::array buffer_; diff --git a/src/http_connection.cpp b/src/http_connection.cpp index fb5655c..c4afef1 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -8,7 +8,7 @@ namespace async_web_server_cpp HttpConnection::HttpConnection(boost::asio::io_context& io_service, HttpServerRequestHandler handler) - : strand_(io_service), socket_(io_service), request_handler_(handler), + : strand_(io_service.get_executor()), socket_(io_service), request_handler_(handler), write_in_progress_(false) { } @@ -77,7 +77,8 @@ void HttpConnection::async_read(ReadHandler callback) } socket_.async_read_some( boost::asio::buffer(buffer_), - strand_.wrap( + boost::asio::bind_executor( + strand_, boost::bind(&HttpConnection::handle_read_raw, shared_from_this(), callback, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); diff --git a/src/http_server.cpp b/src/http_server.cpp index d9f7df6..5b2b66c 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -13,7 +13,7 @@ HttpServer::HttpServer(const std::string& address, const std::string& port, { boost::asio::ip::tcp::resolver resolver(io_service_); - boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(address, port).begin(); + boost::asio::ip::tcp::endpoint endpoint = resolver.resolve(address, port).begin()->endpoint(); acceptor_.open(endpoint.protocol()); acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); acceptor_.bind(endpoint);