本文整理汇总了C++中FindSocketObj函数的典型用法代码示例。如果您正苦于以下问题:C++ FindSocketObj函数的具体用法?C++ FindSocketObj怎么用?C++ FindSocketObj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindSocketObj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CUdpServer::HandleSend(CONNID dwConnID, TUdpBufferObj* pBufferObj)
{
BOOL bNeedFree = FALSE;
switch(m_enSendPolicy)
{
case SP_PACK:
{
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
{
long sndCount = ::InterlockedDecrement(&pSocketObj->sndCount);
TriggerFireSend(dwConnID, pBufferObj);
if(sndCount == 0) DoSendPack(pSocketObj);
}
else
bNeedFree = TRUE;
}
break;
case SP_SAFE:
{
long sndCount = -1;
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
{
sndCount = ::InterlockedDecrement(&pSocketObj->sndCount);
if(sndCount == 0 && !pSocketObj->smooth)
{
CCriSecLock locallock(pSocketObj->crisec);
if((sndCount = pSocketObj->sndCount) == 0)
pSocketObj->smooth = TRUE;
}
TriggerFireSend(dwConnID, pBufferObj);
if(sndCount == 0) DoSendSafe(pSocketObj);
}
else
bNeedFree = TRUE;
}
break;
case SP_DIRECT:
{
TriggerFireSend(dwConnID, pBufferObj);
}
break;
default:
ASSERT(FALSE);
}
if(bNeedFree) AddFreeBufferObj(pBufferObj);
}
示例2: HandleAccept
void CUdpServer::HandleZeroBytes(CONNID dwConnID, TUdpBufferObj* pBufferObj)
{
if(pBufferObj->operation == SO_RECEIVE)
{
if(dwConnID == 0)
dwConnID = HandleAccept(pBufferObj);
if(dwConnID != 0)
{
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
{
pSocketObj->detectFails = 0;
DoSend(pSocketObj, nullptr, 0);
}
TRACE("<S-CNNID: %Iu> recv 0 bytes (detect package)\n", dwConnID);
}
DoReceive(pBufferObj);
}
else
{
ASSERT(dwConnID != 0);
TRACE("<S-CNNID: %Iu> send 0 bytes (detect package)\n", dwConnID);
}
}
示例3: FindSocketObj
void CTcpAgent::AddFreeSocketObj(CONNID dwConnID, EnSocketCloseFlag enFlag, EnSocketOperation enOperation, int iErrorCode)
{
BOOL bDone = FALSE;
TSocketObj* pSocketObj = FindSocketObj(dwConnID);;
if(TUdpSocketObj::IsValid(pSocketObj))
{
CReentrantWriteLock locallock(m_csClientSocket);
if(TSocketObj::IsValid(pSocketObj))
{
TSocketObj::Invalid(pSocketObj);
bDone = TRUE;
}
}
if(bDone)
{
CloseClientSocketObj(pSocketObj, enFlag, enOperation, iErrorCode);
TSocketObj::Release(pSocketObj);
{
CReentrantWriteLock locallock(m_csClientSocket);
m_mpClientSocket.erase(dwConnID);
}
{
CCriSecLock locallock(m_csFreeSocket);
m_lsFreeSocket.push_back(pSocketObj);
}
if(m_lsFreeSocket.size() > m_dwFreeSocketObjHold)
CompressFreeSocket(m_dwFreeSocketObjPool);
}
}
示例4: HandleAccept
void CUdpServer::HandleZeroBytes(CONNID dwConnID, TUdpBufferObj* pBufferObj)
{
if(pBufferObj->operation == SO_RECEIVE)
{
if(dwConnID == 0)
dwConnID = HandleAccept(pBufferObj);
if(dwConnID != 0)
{
TRACE("<S-CNNID: %Iu> recv 0 bytes (detect package)\n", dwConnID);
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
{
pSocketObj->detectFails = 0;
SendDetectPackage(dwConnID, pSocketObj);
}
}
DoReceive(pBufferObj);
}
else
VERIFY(FALSE);
}
示例5: locallock
void CUdpServer::AddFreeSocketObj(CONNID dwConnID)
{
BOOL bDone = FALSE;
TUdpSocketObj* pSocketObj = nullptr;
{
CReentrantWriteLock locallock(m_csClientSocket);
pSocketObj = FindSocketObj(dwConnID);
if(pSocketObj != nullptr)
{
m_mpClientAddr.erase(&pSocketObj->clientAddr);
m_mpClientSocket.erase(dwConnID);
bDone = TRUE;
}
}
if(bDone)
{
{
CCriSecLock locallock(m_csFreeSocket);
pSocketObj->freeTime = ::TimeGetTime();
m_lsFreeSocket.push_back(pSocketObj);
}
if(m_lsFreeSocket.size() > m_dwFreeSocketObjHold)
CompressFreeSocket(m_dwFreeSocketObjPool);
}
}
示例6: FindSocketObj
void CUdpServer::ForceDisconnect(CONNID dwConnID)
{
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
AddFreeSocketObj(dwConnID, SCF_CLOSE);
}
示例7: ASSERT
BOOL CTcpAgent::Send(CONNID dwConnID, const BYTE* pBuffer, int iLength, int iOffset)
{
ASSERT(pBuffer && iLength > 0);
if(iOffset != 0) pBuffer += iOffset;
int result = NO_ERROR;
TSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(!TSocketObj::IsValid(pSocketObj))
result = ERROR_OBJECT_NOT_FOUND;
else
{
CCriSecLock locallock(pSocketObj->crisec);
if(!TSocketObj::IsValid(pSocketObj))
result = ERROR_OBJECT_NOT_FOUND;
else
{
switch(m_enSendPolicy)
{
case SP_PACK: result = SendPack(pSocketObj, pBuffer, iLength); break;
case SP_SAFE: result = SendSafe(pSocketObj, pBuffer, iLength); break;
case SP_DIRECT: result = SendDirect(pSocketObj, pBuffer, iLength); break;
default: ASSERT(FALSE); result = ERROR_INVALID_INDEX; break;
}
}
}
if(result != NO_ERROR)
::SetLastError(result);
return (result == NO_ERROR);
}
示例8: FindSocketObj
int CUdpServer::DoSend(CONNID dwConnID)
{
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TUdpSocketObj::IsValid(pSocketObj))
return DoSend(pSocketObj);
return ERROR_OBJECT_NOT_FOUND;
}
示例9: ASSERT
void CTcpServer::AddClientSocketObj(CONNID dwConnID, TSocketObj* pSocketObj)
{
ASSERT(FindSocketObj(dwConnID) == nullptr);
pSocketObj->connTime = ::TimeGetTime();
pSocketObj->activeTime = pSocketObj->connTime;
VERIFY(m_bfActiveSockets.ReleaseLock(dwConnID, pSocketObj));
}
示例10: FindSocketObj
BOOL CTcpServer::IsConnected(CONNID dwConnID)
{
TSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(TSocketObj::IsValid(pSocketObj))
return pSocketObj->HasConnected();
return FALSE;
}
示例11: locallock
void CUdpServer::AddClientSocketObj(CONNID dwConnID, TUdpSocketObj* pSocketObj)
{
CReentrantWriteLock locallock(m_csClientSocket);
ASSERT(FindSocketObj(dwConnID) == nullptr);
pSocketObj->connTime = ::TimeGetTime();
m_mpClientSocket[dwConnID] = pSocketObj;
m_mpClientAddr [&pSocketObj->clientAddr] = dwConnID;
}
示例12: FindSocketObj
void CUdpServer::ForceDisconnect(CONNID dwConnID)
{
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(pSocketObj != nullptr)
{
FireClose(dwConnID);
AddFreeSocketObj(dwConnID);
}
}
示例13: FindSocketObj
BOOL CIocpServer::GetConnectionAddress(DWORD dwConnID, CString& strAddress, USHORT& usPort)
{
TSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(pSocketObj)
{
strAddress = CA2T(inet_ntoa(pSocketObj->clientAddr.sin_addr));
usPort = ntohs(pSocketObj->clientAddr.sin_port);
}
return pSocketObj != NULL;
}
示例14: RemoveSocketObjByHandle
//
// Function: RemoveSocketObjByHandle
//
// Description:
// Remove the socket object structure from the list of objects that
// matches the socket handle.
//
void RemoveSocketObjByHandle(SOCKET s)
{
SOCKET_OBJ *obj;
obj = FindSocketObj(s);
if (obj)
{
RemoveSocketObj(obj);
}
return;
}
示例15: ASSERT
void CTcpServer::AddClientSocketObj(CONNID dwConnID, TSocketObj* pSocketObj, const HP_SOCKADDR& remoteAddr)
{
ASSERT(FindSocketObj(dwConnID) == nullptr);
pSocketObj->connTime = ::TimeGetTime();
pSocketObj->activeTime = pSocketObj->connTime;
remoteAddr.Copy(pSocketObj->remoteAddr);
pSocketObj->SetConnected();
ENSURE(m_bfActiveSockets.ReleaseLock(dwConnID, pSocketObj));
}