bool CConnectAcceptorManager::CheckIPInfo(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) { return true; } } } return false; }
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; }
uint32 CControlListen::GetListenCount() { m_vecListenList.clear(); if (0 == App_ConnectAcceptorManager::instance()->GetCount()) { //监控尚未启动,需要从配置文件中获取 int nServerPortCount = (int)GetXmlConfigAttribute(xmlTCPServerIPs)->vec.size(); for (int i = 0; i < nServerPortCount; i++) { _ControlInfo objInfo; sprintf_safe(objInfo.m_szListenIP, MAX_BUFF_20, "%s", GetXmlConfigAttribute(xmlTCPServerIPs)->vec[i].ip.c_str()); objInfo.m_u4Port = GetXmlConfigAttribute(xmlTCPServerIPs)->vec[i].port; m_vecListenList.push_back(objInfo); } } else { for (int i = 0; i < App_ConnectAcceptorManager::instance()->GetCount(); i++) { ConnectAcceptor* pConnectAcceptor = App_ConnectAcceptorManager::instance()->GetConnectAcceptor(i); if (NULL != pConnectAcceptor) { _ControlInfo objInfo; sprintf_safe(objInfo.m_szListenIP, MAX_BUFF_20, "%s", pConnectAcceptor->GetListenIP()); objInfo.m_u4Port = pConnectAcceptor->GetListenPort(); m_vecListenList.push_back(objInfo); } } } return (uint32)m_vecListenList.size(); }