diff --git a/src/transport/raw/TCP.cpp b/src/transport/raw/TCP.cpp index cd4571ec145041..d8e9662f5cace7 100644 --- a/src/transport/raw/TCP.cpp +++ b/src/transport/raw/TCP.cpp @@ -53,11 +53,7 @@ constexpr int kListenBacklogSize = 2; } // namespace -TCPBase::~TCPBase() -{ - // Call Close to free the listening socket and close all active connections. - Close(); -} +TCPBase::~TCPBase() = default; void TCPBase::CloseActiveConnections() { diff --git a/src/transport/raw/TCP.h b/src/transport/raw/TCP.h index 4cd63b2b56260e..02375458119fba 100644 --- a/src/transport/raw/TCP.h +++ b/src/transport/raw/TCP.h @@ -338,7 +338,13 @@ class TCP : public TCPBase } } - ~TCP() override { mPendingPackets.ReleaseAll(); } + ~TCP() override + { + mPendingPackets.ReleaseAll(); + + // Call Close to free the listening socket and close all active connections. + Close(); + } private: ActiveTCPConnectionState mConnectionsBuffer[kActiveConnectionsSize];