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


C++ CBaseSocket::ReleaseRef方法代码示例

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


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

示例1: netlib_option

int netlib_option(net_handle_t handle, int opt, void* optval)
{
	CBaseSocket* pSocket = FindBaseSocket(handle);
	if (!pSocket)
		return NETLIB_ERROR;

	if ((opt >= NETLIB_OPT_GET_REMOTE_IP) && !optval)
		return NETLIB_ERROR;

	switch (opt)
	{
	case NETLIB_OPT_SET_CALLBACK:
		pSocket->SetCallback((callback_t)optval);
		break;
	case NETLIB_OPT_SET_CALLBACK_DATA:
		pSocket->SetCallbackData(optval);
		break;
	case NETLIB_OPT_GET_REMOTE_IP:
		*(string*)optval = pSocket->GetRemoteIP();
		break;
	case NETLIB_OPT_GET_REMOTE_PORT:
		*(uint16_t*)optval = pSocket->GetRemotePort();
		break;
	case NETLIB_OPT_GET_LOCAL_IP:
		*(string*)optval = pSocket->GetLocalIP();
		break;
	case NETLIB_OPT_GET_LOCAL_PORT:
		*(uint16_t*)optval = pSocket->GetLocalPort();
	}

	pSocket->ReleaseRef();
	return NETLIB_OK;
}
开发者ID:9618211,项目名称:TTServer,代码行数:33,代码来源:netlib.cpp

示例2: netlib_close

int netlib_close(net_handle_t handle)
{
	CBaseSocket* pSocket = FindBaseSocket(handle);
	if (!pSocket)
		return NETLIB_ERROR;

	int ret = pSocket->Close();
	pSocket->ReleaseRef();
	return ret;
}
开发者ID:narychen,项目名称:egserv,代码行数:10,代码来源:netlib.cpp

示例3: netlib_recv

int netlib_recv(net_handle_t handle, void* buf, int len)
{
	CBaseSocket* pSocket = FindBaseSocket(handle);
	if (!pSocket)
		return NETLIB_ERROR;

	int ret = pSocket->Recv(buf, len);
	pSocket->ReleaseRef();
	return ret;
}
开发者ID:narychen,项目名称:egserv,代码行数:10,代码来源:netlib.cpp

示例4: netlib_send

int netlib_send( net_handle_t handle, void *buf, int len)
{
    CBaseSocket *pSocket = FindBaseSocket(handle);
    if( NULL == pSocket)
    {
        return NETLIB_ERROR;
    }
    int ret = pSocket->Send(buf, len);
    pSocket->ReleaseRef();
    return ret;
}
开发者ID:hgl888,项目名称:Server,代码行数:11,代码来源:netlib.cpp

示例5: netlib_close

int netlib_close(net_handle_t handle)
{
	CBaseSocket* pSocket = FindBaseSocket(handle);
	if (!pSocket)
	{
		LOG__(APP, _T("can not find base socket,handle:%d"),handle);
		return NETLIB_ERROR;
	}

	int ret = pSocket->Close();
	pSocket->ReleaseRef();
	return ret;
}
开发者ID:hgl888,项目名称:TeamTalk,代码行数:13,代码来源:netlib.cpp

示例6: StartDispatch

void CEventDispatch::StartDispatch(uint32_t wait_timeout)
{
	struct epoll_event events[1024];
	int nfds = 0;

    if(running)
        return;
    running = true;

	while (running){
		nfds = epoll_wait(m_epfd, events, 1024, wait_timeout);
		for (int i = 0; i < nfds; i++){
			int ev_fd = events[i].data.fd;
			CBaseSocket* pSocket = FindBaseSocket(ev_fd);
			if (!pSocket)
				continue;

            #ifdef EPOLLRDHUP
            if (events[i].events & EPOLLRDHUP){
            	Logger.Log(INFO, "On Peer Close, socket=%d", ev_fd);
                pSocket->OnClose();
            }
            #endif
            // Commit End

			if (events[i].events & EPOLLIN){
				Logger.Log(INFO, "OnRead, socket=%d\n", ev_fd);
				pSocket->OnRead();
			}

			if (events[i].events & EPOLLOUT){
				Logger.Log(INFO, "OnWrite, socket=%d\n", ev_fd);
				pSocket->OnWrite();
			}

			if (events[i].events & (EPOLLPRI | EPOLLERR | EPOLLHUP)){
				Logger.Log(INFO, "OnClose, socket=%d\n", ev_fd);
				pSocket->OnClose();
			}

			pSocket->ReleaseRef();
		}

		_CheckTimer();
        _CheckLoop();
	}
}
开发者ID:hhq163,项目名称:NewMessage,代码行数:47,代码来源:EventDispatch.cpp

示例7: netlib_option

int netlib_option( net_handle_t handel, int opt, void *optval)
{
    CBaseSocket *pSocket = FindBaseSocket(handel);
    if( NULL == pSocket )
    {
        return NETLIB_ERROR;
    }
    
    if((opt >= NETLIB_OPT_GET_REMOTE_IP) && !optval )
    {
        return NETLIB_ERROR;
    }
    
    switch (opt) {
        case NETLIB_OPT_SET_CALLBACK:
            pSocket->SetCallback((callback_t)optval);
            break;
        case NETLIB_OPT_SET_CALLBACK_DATA:
            pSocket->SetCallbackData(optval);
            break;
        case NETLIB_OPT_GET_REMOTE_IP:
            *(string*)optval = pSocket->GetRemoteIP();
            break;
        case NETLIB_OPT_GET_REMOTE_PORT:
            *(string*)optval = pSocket->GetRemotePort();
            break;
        case NETLIB_OPT_GET_LOCAL_IP:
            *(string*)optval = pSocket->GetLocalIP();
            break;
        case NETLIB_OPT_GET_LOCAL_PORT:
            *(string*)optval = pSocket->GetLocalPort();
            break;
        case NETLIB_OPT_SET_SEND_BUF_SIZE:
            pSocket->SetSendBufSize(*(uint32_t*)optval);
            break;
        case NETLIB_OPT_SET_RECV_BUF_SIZE:
            pSocket->SetRecvBufSize(*(uint32_t*)optval);
            break;
    }
    pSocket->ReleaseRef();
    return NETLIB_OK;
}
开发者ID:hgl888,项目名称:Server,代码行数:42,代码来源:netlib.cpp

示例8: StartDispatch

void CEventDispatch::StartDispatch(uint32_t wait_timeout)
{
	struct epoll_event events[1024];
	int nfds = 0;
    
	while (running)
	{
		nfds = epoll_wait(m_epfd, events, 1024, wait_timeout);
		for (int i = 0; i < nfds; i++)
		{
			int ev_fd = events[i].data.fd;
			CBaseSocket* pSocket = FindBaseSocket(ev_fd);
			if (!pSocket)
				continue;

			if (events[i].events & EPOLLIN)
			{
				//LOG__(NET,  "OnRead, socket=%d\n", ev_fd);
				pSocket->OnRead();
			}

			if (events[i].events & EPOLLOUT)
			{
				//LOG__(NET,  "OnWrite, socket=%d\n", ev_fd);
				pSocket->OnWrite();
			}

			if (events[i].events & (EPOLLPRI | EPOLLERR | EPOLLHUP))
			{
				//LOG__(NET,  "OnClose, socket=%d\n", ev_fd);
				pSocket->OnClose();
			}

			pSocket->ReleaseRef();
		}

		_CheckTimer();
		_CheckLoop();
	}
}
开发者ID:hgl888,项目名称:TeamTalk,代码行数:40,代码来源:EventDispatch.cpp

示例9: StartDispatch

void CEventDispatch::StartDispatch()
{
    struct epoll_event events[1024];
    int nfds = 0;

    while (true)
    {
        nfds = epoll_wait(m_epfd, events, 1024, MIN_TIMER_DURATION);
        for (int i = 0; i < nfds; i++)
        {
            int ev_fd = events[i].data.fd;
            CBaseSocket* pSocket = FindBaseSocket(ev_fd);
            if (!pSocket)
                continue;

            if (events[i].events & EPOLLIN)
            {
                //log("OnRead, socket=%d\n", ev_fd);
                pSocket->OnRead();
            }

            if (events[i].events & EPOLLOUT)
            {
                //log("OnWrite, socket=%d\n", ev_fd);
                pSocket->OnWrite();
            }

            if (events[i].events & (EPOLLPRI | EPOLLERR | EPOLLHUP))
            {
                //log("OnClose, socket=%d\n", ev_fd);
                pSocket->OnClose();
            }

            pSocket->ReleaseRef();
        }

        _CheckTimer();
    }
}
开发者ID:houzhenggang,项目名称:TTServer-1,代码行数:39,代码来源:EventDispatch.cpp


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