本文整理汇总了C++中TCPConnection::Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPConnection::Disconnect方法的具体用法?C++ TCPConnection::Disconnect怎么用?C++ TCPConnection::Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPConnection
的用法示例。
在下文中一共展示了TCPConnection::Disconnect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TCPConnectionLoop
ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp)
{
#ifdef _WINDOWS
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif
if (tmp == 0)
{
THREAD_RETURN(nullptr);
}
TCPConnection* tcpc = (TCPConnection*) tmp;
#ifndef WIN32
//Log.Out(Logs::Detail, Logs::TCP_Connection, "%s Starting TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self());
#endif
tcpc->MLoopRunning.lock();
while (tcpc->RunLoop())
{
Sleep(LOOP_GRANULARITY);
if (!tcpc->ConnectReady())
{
if (!tcpc->Process())
{
//the processing loop has detecting an error..
//we want to drop the link immediately, so we clear buffers too.
tcpc->ClearBuffers();
tcpc->Disconnect();
}
Sleep(1);
}
else if (tcpc->GetAsyncConnect())
{
tcpc->SetAsyncConnect(false);
}
else
{
Sleep(10); //nothing to do.
}
}
tcpc->MLoopRunning.unlock();
#ifndef WIN32
//Log.Out(Logs::Detail, Logs::TCP_Connection, "%s Ending TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self());
#endif
THREAD_RETURN(nullptr);
}
示例2: TCPConnectionLoop
ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
#ifdef _WINDOWS
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif
if (tmp == 0) {
THREAD_RETURN(NULL);
}
TCPConnection* tcpc = (TCPConnection*) tmp;
#ifndef WIN32
_log(COMMON__THREADS, "Starting TCPConnectionLoop with thread ID %d", pthread_self());
#endif
tcpc->MLoopRunning.lock();
while (tcpc->RunLoop()) {
Sleep(LOOP_GRANULARITY);
if (!tcpc->ConnectReady()) {
_CP(TCPConnectionLoop);
if (!tcpc->Process()) {
//the processing loop has detecting an error..
//we want to drop the link immediately, so we clear buffers too.
tcpc->ClearBuffers();
tcpc->Disconnect();
}
Sleep(1);
}
else if (tcpc->GetAsyncConnect()) {
_CP(TCPConnectionLoop);
if (tcpc->charAsyncConnect)
tcpc->Connect(tcpc->charAsyncConnect, tcpc->GetrPort());
else
tcpc->ConnectIP(tcpc->GetrIP(), tcpc->GetrPort());
tcpc->SetAsyncConnect(false);
}
else
Sleep(10); //nothing to do.
}
tcpc->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(NULL);
}