Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/bitcoin/network/io/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/io/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions test/io/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand All @@ -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)
{
Expand Down
Loading