TcpServer::~TcpServer() { this->cleanupClosedConnections(); std::vector<TcpConnection*>::iterator it = currentConnections.begin(); while (it != currentConnections.end()) { TcpConnection* connection = *it; connection->stop(); delete connection; currentConnections.erase(it++); } }