diff --git a/boost/network/protocol/http/server/async_connection.hpp b/boost/network/protocol/http/server/async_connection.hpp index 915c6fb98..eca2f6807 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); + std::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 16fafc665..fe9d63955 100644 --- a/boost/network/protocol/stream_handler.hpp +++ b/boost/network/protocol/stream_handler.hpp @@ -109,12 +109,21 @@ struct stream_handler { } } - tcp_socket::endpoint_type remote_endpoint() const { + tcp_socket::endpoint_type remote_endpoint(std::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 { + std::error_code ec; + tcp_socket::endpoint_type r = remote_endpoint(ec); + if (ec) { + ::asio::detail::throw_error(ec, "remote_endpoint"); } + return r; } void shutdown(::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