本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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();
}
}