void CConnectAcceptorManager::Close() { for (int i = 0; i < (int)m_vecConnectAcceptor.size(); i++) { ConnectAcceptor* pConnectAcceptor = (ConnectAcceptor*)m_vecConnectAcceptor[i]; if (NULL != pConnectAcceptor) { pConnectAcceptor->close(); delete pConnectAcceptor; pConnectAcceptor = NULL; } } m_vecConnectAcceptor.clear(); m_nAcceptorCount = 0; }
bool CConnectAcceptorManager::Close(const char* pIP, uint32 n4Port) { //找到符合条件指定的端口停止监听 for(vecConnectAcceptor::iterator b = m_vecConnectAcceptor.begin(); b != m_vecConnectAcceptor.end(); b++) { ConnectAcceptor* pConnectAcceptor = (ConnectAcceptor*)(*b); if (NULL != pConnectAcceptor) { if(ACE_OS::strcmp(pConnectAcceptor->GetListenIP(), pIP) == 0 && pConnectAcceptor->GetListenPort() == n4Port) { pConnectAcceptor->close(); SAFE_DELETE(pConnectAcceptor); m_vecConnectAcceptor.erase(b); break; } } } return true; }