diff --git a/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp b/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp index bbffb0fd924..46eb6d9b15f 100644 --- a/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp +++ b/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp @@ -115,11 +115,6 @@ void TCPChannelResourceBasic::disconnect() try { socket->cancel(); - - // This method was added on the version 1.12.0 -#if ASIO_VERSION >= 101200 && (!defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0603) - socket->release(); -#endif // if ASIO_VERSION >= 101200 && (!defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0603) socket->close(); } catch (std::exception&) diff --git a/src/cpp/rtps/transport/UDPChannelResource.cpp b/src/cpp/rtps/transport/UDPChannelResource.cpp index 4d854df0767..61c75a60511 100644 --- a/src/cpp/rtps/transport/UDPChannelResource.cpp +++ b/src/cpp/rtps/transport/UDPChannelResource.cpp @@ -45,6 +45,9 @@ UDPChannelResource::UDPChannelResource( UDPChannelResource::~UDPChannelResource() { message_receiver_ = nullptr; + + asio::error_code ec; + socket()->close(ec); } void UDPChannelResource::perform_listen_operation( @@ -117,8 +120,11 @@ void UDPChannelResource::release() // in Windows and Linux anyways, which is what we want. asio::error_code ec; socket()->shutdown(asio::socket_base::shutdown_type::shutdown_receive, ec); - // On OSX shutdown does not unblock the listening thread, but close does. + +#if defined(__APPLE__) + // On OSX shutdown does not seem to unblock the listening thread, but close does. socket()->close(); +#endif // if defined(__APPLE__) } } // namespace rtps