关于HPSocket的问题

盆栽里有熊猫 发布于 2016/10/12 14:29
阅读 275
收藏 0

@伤神小怪兽 你好,想跟你请教个问题:

我想通过调用GetAllConnectionIDs去获取连接的ID

DWORD dwCount = 0;
CONNID pIDs[10000]; ZeroMemory(pIDs, 10000);
if (m_tcpServer->GetAllConnectionIDs(pIDs, dwCount))

{

}

每次调用GetAllConnectionIDs返回FALSE,我看了源代码中

BOOL isOK = FALSE;
DWORD dwSize = 0;
{
CReentrantReadLock locallock(m_csClientSocket);
dwSize = (DWORD)m_mpClientSocket.size();
if(pIDs != nullptr && dwSize <= dwCount)
{
TSocketObjPtrMapCI it = m_mpClientSocket.begin();
TSocketObjPtrMapCI end = m_mpClientSocket.end();

for(int i = 0; it != end; ++it, ++i)
pIDs[i] = it->first;

isOK = TRUE;
}
}

dwCount = dwSize;
return isOK;

也只有if(pIDs != nullptr && dwSize <= dwCount)这个条件不满足才会返回FALSE,但是我的参数应该是会满足的,实在不解,想请教下。

加载中
0
伤神小怪兽
伤神小怪兽
DWORD dwCount = 0;
CONNID pIDs[10000]; ZeroMemory(pIDs, 10000);
if (m_tcpServer->GetAllConnectionIDs(pIDs, dwCount))

DWORD dwCount = 10000;
返回顶部
顶部