91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 18.43MB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-08-02
  • 語言: C/C++
  • 標簽: c++??線程池??服務器??

資源簡介

c++ 多線程 線程池服務器程序 和 客戶端程序 ,這是一個已經測試過的例子,編譯環(huán)境為vs2013,有興趣的,可以下載運行學習

資源截圖

代碼片段和文件信息



#include?“stdafx.h“

#include?

#include?“HandleCon.h“

extern?int?g_ClientNum;

HandleCon::HandleCon()
{
m_handleThreadSem?=?CreateSemaphore(NULL?0?1?NULL);
m_useState?=?false;
CreateHandleThread();
}
HandleCon::~HandleCon()
{
}

unsigned?WINAPI?HandleCon::HandlePro(LPVOID?lparam)
{
HandleCon?*hPro?=?(HandleCon?*)lparam;
while?(!hPro->m_useState)
{

WaitForSingleobject(hPro->m_handleThreadSem?INFINITE);
hPro->StartHandleRequst();
}
return?0;
}

void?HandleCon::CreateHandleThread()
{
HANDLE?hThread;
hThread?=?(HANDLE)::_beginthreadex(NULL?0?HandlePro?(LPVOID)this?0?NULL);
}

void?HandleCon::StartHandleRequst()
{
fd_set?read_fds;
FD_ZERO(&read_fds);
timeval?tv?=?{?1?0?};
char?buf[MAXSIZE];
memset(buf?0?sizeof(MAXSIZE));
std::cout?<“?<:“< while?(true)
{
//從不開始收數(shù)據開始計算,如果超過OVERTIME客戶端沒有發(fā)來請求,服務器會斷開此連接
FD_SET(m_confd?&read_fds);
if?(select(m_confd?+?1?&read_fds?0?0?&tv)? {
std::cout?< break;
}
if?(FD_ISSET(m_confd?&read_fds))
{
int?ret?=?recv(m_confd?buf?sizeof(buf)?-?1?0);
if?(ret?<=?0)
{
break;
}
else
{
std::cout?< }
}
}
closesocket(m_confd);
m_useState?=?false;
g_ClientNum--;
}

void?HandleCon::ReleaseOneThread(SOCKET?confd?std::string?clientIP?UINT32?clientPort)
{
m_confd?=?confd;
m_useState?=?true;
m_ip?=?clientIP;
m_port?=?clientPort;
ReleaseSemaphore(m_handleThreadSem?1?NULL);
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????97280??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\Debug\mulThreadServer.exe

?????文件?????555564??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\Debug\mulThreadServer.ilk

?????文件????1363968??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\Debug\mulThreadServer.pdb

?????文件????3538944??2016-10-11?20:37??多線程服務器程序例子\mulThreadServer\ipch\multhreadserver-ea689699\multhreadserver-62278207.ipch

?????文件????3080192??2016-10-13?18:54??多線程服務器程序例子\mulThreadServer\ipch\multhreadserver-ea689699\multhreadserver-93182609.ipch

?????文件?????175008??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\HandleCon.obj

?????文件?????267586??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\HandleThreadPool.obj

?????文件???????1372??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.Build.CppClean.log

?????文件???????1629??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.log

?????文件?????168523??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.obj

?????文件????1703936??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.pch

?????文件???????3050??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\cl.command.1.tlog

?????文件??????89942??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\CL.read.1.tlog

?????文件???????2626??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\CL.write.1.tlog

?????文件???????1690??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\link.command.1.tlog

?????文件???????3524??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\link.read.1.tlog

?????文件????????854??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\link.write.1.tlog

?????文件????????174??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\mulThreadServer.tlog\mulThreadServer.lastbuildstate

?????文件??????11793??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\stdafx.obj

?????文件????1051648??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\vc120.idb

?????文件?????544768??2016-10-13?19:12??多線程服務器程序例子\mulThreadServer\mulThreadServer\Debug\vc120.pdb

?????文件???????1772??2016-10-13?18:50??多線程服務器程序例子\mulThreadServer\mulThreadServer\HandleCon.cpp

?????文件????????500??2016-10-13?17:06??多線程服務器程序例子\mulThreadServer\mulThreadServer\HandleCon.h

?????文件???????1273??2016-10-13?18:30??多線程服務器程序例子\mulThreadServer\mulThreadServer\HandleThreadPool.cpp

?????文件????????493??2016-10-13?17:51??多線程服務器程序例子\mulThreadServer\mulThreadServer\HandleThreadPool.h

?????文件???????2222??2016-10-13?18:49??多線程服務器程序例子\mulThreadServer\mulThreadServer\mulThreadServer.cpp

?????文件???????8148??2016-10-12?11:22??多線程服務器程序例子\mulThreadServer\mulThreadServer\mulThreadServer.vcxproj

?????文件???????1736??2016-10-12?11:22??多線程服務器程序例子\mulThreadServer\mulThreadServer\mulThreadServer.vcxproj.filters

?????文件???????1771??2016-10-09?21:18??多線程服務器程序例子\mulThreadServer\mulThreadServer\ReadMe.txt

?????文件????????302??2016-10-09?21:18??多線程服務器程序例子\mulThreadServer\mulThreadServer\stdafx.cpp

............此處省略69個文件信息

評論

共有 條評論