diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/async_connection.hpp index d73dbff9f..2634afb62 100644 --- a/boost/network/protocol/http/server/async_connection.hpp +++ b/boost/network/protocol/http/server/async_connection.hpp @@ -462,11 +462,18 @@ struct async_connection enum state_t { method, uri, version, headers }; void start() { - typename ostringstream::type ip_stream; - ip_stream << socket_.remote_endpoint().address().to_string() << ':' - << socket_.remote_endpoint().port(); - request_.source = ip_stream.str(); - read_more(method); + boost::system::error_code ec; + auto remote_endpoint = socket_.remote_endpoint(ec); + + if (ec) { + error_encountered = in_place(ec); + } else { + typename ostringstream::type ip_stream; + ip_stream << remote_endpoint.address().to_string() << ':' + << remote_endpoint.port(); + request_.source = ip_stream.str(); + read_more(method); + } } void read_more(state_t state) { diff --git a/boost/network/protocol/stream_handler.hpp b/boost/network/protocol/stream_handler.hpp index 7af02f3a1..2231af0cf 100644 --- a/boost/network/protocol/stream_handler.hpp +++ b/boost/network/protocol/stream_handler.hpp @@ -103,12 +103,21 @@ struct stream_handler { } } - tcp_socket::endpoint_type remote_endpoint() const { + tcp_socket::endpoint_type remote_endpoint(boost::system::error_code& ec) const { if (ssl_enabled) { - return ssl_sock_->next_layer().remote_endpoint(); + return ssl_sock_->next_layer().remote_endpoint(ec); } else { - return tcp_sock_->remote_endpoint(); + return tcp_sock_->remote_endpoint(ec); + } + } + + tcp_socket::endpoint_type remote_endpoint() const { + boost::system::error_code ec; + tcp_socket::endpoint_type r = remote_endpoint(ec); + if (ec) { + boost::asio::detail::throw_error(ec, "remote_endpoint"); } + return r; } void shutdown(boost::asio::socket_base::shutdown_type st, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy