Example #1
0
CConnection* CNetManager::AssociateCompletePort( SOCKET hSocket )
{
	CConnection *pConnection = CConnectionMgr::GetInstancePtr()->CreateConnection();

	pConnection->SetSocket(hSocket);

	pConnection->SetDataHandler(m_pBufferHandler);

	if(NULL == CreateIoCompletionPort((HANDLE)hSocket, m_hCompletePort, (ULONG_PTR)pConnection, 0))
	{
		pConnection->Close(FALSE);

		return NULL;
	}

	return pConnection;
}
Example #2
0
CConnection* CNetManager::AssociateCompletePort( SOCKET hSocket )
{
	CConnection *pConnection = CConnectionMgr::GetInstancePtr()->CreateConnection();

	pConnection->SetSocket(hSocket);

	pConnection->SetDataHandler(m_pBufferHandler);

	struct epoll_event EpollEvent;
	EpollEvent.data.ptr= pConnection;
	EpollEvent.events  = EPOLLIN|EPOLLOUT|EPOLLET;

	if(-1 == epoll_ctl(m_hCompletePort, EPOLL_CTL_ADD, hSocket,&EpollEvent))
	{
		pConnection->Close(FALSE);

		CConnectionMgr::GetInstancePtr()->DeleteConnection(pConnection);

		return NULL;
	}

	return pConnection;
}