diff --git a/include/bitcoin/network/io/socket.hpp b/include/bitcoin/network/io/socket.hpp index 5184c4282..5bea556a1 100644 --- a/include/bitcoin/network/io/socket.hpp +++ b/include/bitcoin/network/io/socket.hpp @@ -115,7 +115,7 @@ class BCT_API socket size_t available(code& ec) const NOEXCEPT; /// The peer has closed its side of the connection (FIN received), - /// or reset it (RST received, linux, macos and windows). + /// or reset it (RST received). bool half_closed() const NOEXCEPT; endpoint local_endpoint(code& ec) const NOEXCEPT; diff --git a/src/io/socket.cpp b/src/io/socket.cpp index 167d09281..2c59740c3 100644 --- a/src/io/socket.cpp +++ b/src/io/socket.cpp @@ -405,6 +405,9 @@ bool socket::half_closed() const NOEXCEPT if (is_zero(::getsockopt(descriptor_->handle, IPPROTO_TCP, TCP_INFO, &info, &size))) return info.tcpi_state == TCPS_CLOSE_WAIT; + + if (last_error() == ECONNRESET) + return true; #endif return false; } diff --git a/test/io/socket.cpp b/test/io/socket.cpp index 0c5d14a60..11b769b7c 100644 --- a/test/io/socket.cpp +++ b/test/io/socket.cpp @@ -459,7 +459,6 @@ BC_AUTO_TEST_CASE(io_socket__half_closed__peer_shutdown_with_unread_data__true) BC_REQUIRE(!ec); } -#if defined(HAVE_LINUX) || defined(HAVE_APPLE) || defined(HAVE_WINDOWS) BC_AUTO_TEST_CASE(io_socket__half_closed__peer_reset__true) { connected_pair connection{}; @@ -474,7 +473,6 @@ BC_AUTO_TEST_CASE(io_socket__half_closed__peer_reset__true) BC_REQUIRE(half_closed_within(connection.accepted, 1000)); } -#endif BC_AUTO_TEST_CASE(io_socket__half_closed__opened_unconnected__false) {