From 43962f41031d85778e4ae5949ec1a6141a1bcac2 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 27 Mar 2016 12:53:20 +0100 Subject: abstract_tcp_server2: possible fix for exception in handle_accept --- contrib/epee/include/net/abstract_tcp_server2.inl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'contrib/epee/include/net/abstract_tcp_server2.inl') diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 1c854dfb7..b3d4e5fdb 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -252,11 +252,24 @@ PRAGMA_WARNING_DISABLE_VS(4355) template void connection::save_dbg_log() { + std::string address, port; + boost::system::error_code e; + + boost::asio::ip::tcp::endpoint endpoint = socket_.remote_endpoint(e); + if (e) + { + address = ""; + port = ""; + } + else + { + address = endpoint.address().to_string(); + port = boost::lexical_cast(endpoint.port()); + } _mark_c("net/kind" , - " connection type " << to_string( m_connection_type ) << " " - << socket_.local_endpoint().address().to_string() << ":" << socket_.local_endpoint().port() - << " <--> " << socket_.remote_endpoint().address().to_string() << ":" << socket_.remote_endpoint().port() - ); + " connection type " << to_string( m_connection_type ) << " " + << socket_.local_endpoint().address().to_string() << ":" << socket_.local_endpoint().port() + << " <--> " << address << ":" << port); } //--------------------------------------------------------------------------------- template -- cgit v1.2.3