• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FindSocketObj函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
}
开发者ID:grasswin,项目名称:HP-Socket,代码行数:59,代码来源:UdpServer.cpp


示例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);
	}
}
开发者ID:JeffLi1993,项目名称:HP-Socket,代码行数:28,代码来源:UdpServer.cpp


示例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);
	}
}
开发者ID:MatzYang,项目名称:HP-Socket,代码行数:35,代码来源:TcpAgent.cpp


示例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);
}
开发者ID:grasswin,项目名称:HP-Socket,代码行数:25,代码来源:UdpServer.cpp


示例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);
	}
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:30,代码来源:UdpServer.cpp


示例6: FindSocketObj

void CUdpServer::ForceDisconnect(CONNID dwConnID)
{
	TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);

	if(TUdpSocketObj::IsValid(pSocketObj))
		AddFreeSocketObj(dwConnID, SCF_CLOSE);
}
开发者ID:JeffLi1993,项目名称:HP-Socket,代码行数:7,代码来源:UdpServer.cpp


示例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);
}
开发者ID:MatzYang,项目名称:HP-Socket,代码行数:34,代码来源:TcpAgent.cpp


示例8: FindSocketObj

int CUdpServer::DoSend(CONNID dwConnID)
{
	TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);

	if(TUdpSocketObj::IsValid(pSocketObj))
		return DoSend(pSocketObj);

	return ERROR_OBJECT_NOT_FOUND;
}
开发者ID:grasswin,项目名称:HP-Socket,代码行数:9,代码来源:UdpServer.cpp


示例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));
}
开发者ID:ExpLife0011,项目名称:JsModule,代码行数:9,代码来源:TcpServer.cpp


示例10: FindSocketObj

BOOL CTcpServer::IsConnected(CONNID dwConnID)
{
	TSocketObj* pSocketObj = FindSocketObj(dwConnID);

	if(TSocketObj::IsValid(pSocketObj))
		return pSocketObj->HasConnected();

	return FALSE;
}
开发者ID:huazhipeng,项目名称:HP-Socket,代码行数:9,代码来源:TcpServer.cpp


示例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;
}
开发者ID:JeffLi1993,项目名称:HP-Socket,代码行数:10,代码来源:UdpServer.cpp


示例12: FindSocketObj

void CUdpServer::ForceDisconnect(CONNID dwConnID)
{
	TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);

	if(pSocketObj != nullptr)
	{
		FireClose(dwConnID);
		AddFreeSocketObj(dwConnID);
	}
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:10,代码来源:UdpServer.cpp


示例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;
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:11,代码来源:IocpServer.cpp


示例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;
}
开发者ID:c3827286,项目名称:NetworkProgrammingForMicrosoftWindows2e,代码行数:18,代码来源:asyncserver.cpp


示例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));
}
开发者ID:huazhipeng,项目名称:HP-Socket,代码行数:12,代码来源:TcpServer.cpp



注:本文中的FindSocketObj函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FindString函数代码示例发布时间:2022-05-30
下一篇:
C++ FindSection函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap