当前位置: 首页>>代码示例>>C++>>正文


C++ CSocket::GetStatus方法代码示例

本文整理汇总了C++中CSocket::GetStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ CSocket::GetStatus方法的具体用法?C++ CSocket::GetStatus怎么用?C++ CSocket::GetStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSocket的用法示例。


在下文中一共展示了CSocket::GetStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Poll

EIO_Status CSocketAPI::Poll(vector<SPoll>&  polls,
                            const STimeout* timeout,
                            size_t*         n_ready)
{
    static const STimeout kZero = {0, 0};
    size_t          x_n     = polls.size();
    SPOLLABLE_Poll* x_polls = 0;
    size_t          x_ready = 0;

    if (x_n  &&  !(x_polls = new SPOLLABLE_Poll[x_n]))
        return eIO_Unknown;

    for (size_t i = 0;  i < x_n;  i++) {
        CPollable* p     = polls[i].m_Pollable;
        EIO_Event  event = polls[i].m_Event;
        if (p  &&  event) {
            CSocket* s = dynamic_cast<CSocket*> (p);
            if (!s) {
                CListeningSocket* ls = dynamic_cast<CListeningSocket*> (p);
                if (!ls) {
                    CTrigger* tr = dynamic_cast<CTrigger*> (p);
                    x_polls[i].poll = POLLABLE_FromTRIGGER(tr
                                                           ? tr->GetTRIGGER()
                                                           : 0);
                } else
                    x_polls[i].poll = POLLABLE_FromLSOCK(ls->GetLSOCK());
                polls[i].m_REvent = eIO_Open;
            } else {
                EIO_Event revent;
                if (s->GetStatus(eIO_Open) != eIO_Closed) {
                    x_polls[i].poll = POLLABLE_FromSOCK(s->GetSOCK());
                    revent = eIO_Open;
                } else {
                    x_polls[i].poll = 0;
                    revent = eIO_Close;
                    x_ready++;
                }
                polls[i].m_REvent = revent;
            }
            x_polls[i].event = event;
        } else {
            x_polls[i].poll = 0;
            polls[i].m_REvent = eIO_Open;
        }
    }

    size_t xx_ready;
    EIO_Status status = POLLABLE_Poll(x_n, x_polls,
                                      x_ready ? &kZero : timeout, &xx_ready);

    for (size_t i = 0;  i < x_n;  i++) {
        if (x_polls[i].revent)
            polls[i].m_REvent = x_polls[i].revent;
    }

    if (n_ready)
        *n_ready = xx_ready + x_ready;

    delete[] x_polls;
    return status;
}
开发者ID:timothyjlaurent,项目名称:nacl_blast,代码行数:61,代码来源:ncbi_socket_cxx.cpp

示例2: HandleMessage

int32_t CEpoll::HandleMessage(int32_t nWaitTimeout)
{
	if(m_nEpollFD < 0)
	{
		return -1;
	}

	int32_t nEventCount = epoll_wait(m_nEpollFD, m_pEpollEvent, m_nMaxFD, nWaitTimeout);
	if(nEventCount < 0)
	{
		return -1;
	}

	for(int32_t i = 0; i < nEventCount; ++i)
	{
		CSocket *pSocket = (CSocket *)m_pEpollEvent[i].data.ptr;
		if(pSocket == NULL)
		{
			continue;
		}

		if((m_pEpollEvent[i].events & EPOLLIN) != 0)
		{
			pSocket->ReadEvent();

			SocketStatus nSocketStatus = pSocket->GetStatus();
			if((nSocketStatus == enmSocketStatus_Closed) || (nSocketStatus == enmSocketStatus_Error))
			{
				continue;
			}
		}
		if((m_pEpollEvent[i].events & EPOLLOUT) != 0)
		{
			pSocket->WriteEvent();

			SocketStatus nSocketStatus = pSocket->GetStatus();
			if((nSocketStatus == enmSocketStatus_Closed) || (nSocketStatus == enmSocketStatus_Error))
			{
				continue;
			}
		}
		if((m_pEpollEvent[i].events & EPOLLERR) != 0)
		{
			pSocket->ErrorEvent();

			SocketStatus nSocketStatus = pSocket->GetStatus();
			if((nSocketStatus == enmSocketStatus_Closed) || (nSocketStatus == enmSocketStatus_Error))
			{
				continue;
			}
		}
		if((m_pEpollEvent[i].events & EPOLLHUP) != 0)
		{
			pSocket->ErrorEvent();

			SocketStatus nSocketStatus = pSocket->GetStatus();
			if((nSocketStatus == enmSocketStatus_Closed) || (nSocketStatus == enmSocketStatus_Error))
			{
				continue;
			}
		}
		if(!(m_pEpollEvent[i].events & EPOLLIN) &&
				!(m_pEpollEvent[i].events & EPOLLOUT) &&
				!(m_pEpollEvent[i].events & EPOLLERR) &&
				!(m_pEpollEvent[i].events & EPOLLHUP))
		{
			g_FrameLogEngine.WriteNetioLog(enmLogLevel_Error, "it's not found ioevent = 0x%08x\n", m_pEpollEvent[i].events);
		}
	}

	return nEventCount;
}
开发者ID:brianserv,项目名称:lightframe,代码行数:72,代码来源:frame_epoll.cpp


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