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

  • 大小: 28KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-20
  • 語言: 其他
  • 標簽: IOCP??

資源簡介

我們的一個項目的服務器端通信層,IOCP類是在此基礎上寫的,使用了近半年,并發量不大,1k上下,(不過曾做過壓力測試,10k的并發量沒有問題)還算比較穩定,基本上滿足需求。

資源截圖

代碼片段和文件信息

////////////////////////////////////////////////////////////////////////////////////////////////////
// Module?Name:
// IOCPNetTest.cpp
// Author:
// Chun-Hyok?Chong.
// Description:
// IOCPNet?test?code.
////////////////////////////////////////////////////////////////////////////////////////////////////

#include?“stdafx.h“
#include?“workframe.h“
#include?“WorkframeReturnCode.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“IOCPNet.h“

#define?TEST_IP “127.0.0.1“?//?change?it!
#define?TEST_PORT 20000

#define?TEST_LOG_PATH “c:\\\\testlog\\log.txt“

#define?WAIT_TIMEOUT_TEST 100

DWORD?WINAPI?LogicThread(void?*pParam);
void?MainLogic(OIOCPNet?*pIOCPNet?DWORD?SocketUnique?OBufferedSocket?*pBuffSock?BYTE?*pReadData?DWORD?ReadSize);

DWORD?g_dRunning;

int?_tmain(int?argc?_TCHAR*?argv[])
{
OErrLog?EL;
OIOCPNet?*pIOCPNet;
int?key;
WSADATA?WSAData;
HANDLE?hThread;

WSAStartup(MAKEWORD(22)?&WSAData);

EL.SetErrLogFile(TEST_LOG_PATH);

pIOCPNet?=?new?OIOCPNet(&EL);
pIOCPNet->Start(TEST_IP?TEST_PORT);

InterlockedExchange((long?*)&g_dRunning?1);

hThread?=?CreateThread(0?0?LogicThread?pIOCPNet?0?0);
if?(0?==?hThread)
{
printf(“CreateThread?is?failed.?Error?code?=?%d\n“?GetLastError());
goto?ErrHand;
}

printf(“Server:?Press?any?key?to?stop...\n“);
key?=?getch();

InterlockedExchange((long?*)&g_dRunning?0);
WaitForSingleobject(hThread?INFINITE);

ErrHand:
pIOCPNet->Stop();
delete?pIOCPNet;

WSACleanup();

return?0;
}?//?_tmain()

DWORD?WINAPI?LogicThread(void?*pParam)
{
int?iRes;
OIOCPNet?*pIOCPNet;
int?EventType;
DWORD?SocketUnique;
BYTE?*pReadData;
DWORD?ReadSize;
OBufferedSocket?*pBuffSock;
OReadSlotElement?*pSlot;
void?*pCustData;?//?for?formatting.?no?custom?data?is?used?in?this?test.

pIOCPNet?=?(OIOCPNet?*)pParam;

while?(1?==?InterlockedExchange((long?*)&g_dRunning?g_dRunning))
{
iRes?=?pIOCPNet->GetSocketEventData(WAIT_TIMEOUT_TEST?&EventType?&SocketUnique?&pReadData?&ReadSize?&pBuffSock?&pSlot?&pCustData);
if?(RET_TIMEOUT?==?iRes)
{
continue;
}
else?if?(RET_FAIL?==?iRes)
{
return?0;
}
else?if?(RET_SOCKET_CLOSED?==?iRes)
{
//?release?pCustData.
continue;
}

//?Process?main?logic.
MainLogic(pIOCPNet?SocketUnique?pBuffSock?pReadData?ReadSize);

pIOCPNet->ReleaseSocketEvent(pSlot);
}

return?0;
}?//?LogicThread()

void?MainLogic(OIOCPNet?*pIOCPNet?DWORD?SocketUnique?OBufferedSocket?*pBuffSock?BYTE?*pReadData?DWORD?ReadSize)
{
//printf(“pReadData?=?%s\n“?pReadData);
pIOCPNet->WriteData(SocketUnique?pBuffSock?pReadData?ReadSize);?//?echo.

return;
}?//?MainLogic()

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2877??2005-10-28?11:33??IOCPNetTest\IOCPNetTest\IOCPNetTest.cpp
?????文件??????????21??2005-08-24?22:46??IOCPNetTest\IOCPNetTest\stdafx.cpp
?????文件?????????101??2005-08-24?22:45??IOCPNetTest\IOCPNetTest\stdafx.h
?????文件????????3856??2005-08-29?10:53??NetTestClient\NetTestClient\NetTestClient.cpp
?????文件??????????21??2005-08-24?22:48??NetTestClient\NetTestClient\stdafx.cpp
?????文件?????????153??2005-08-24?22:49??NetTestClient\NetTestClient\stdafx.h
?????文件????????8038??2005-08-01?10:32??workframe\errlog.cpp
?????文件????????1046??2005-07-27?17:00??workframe\errlog.h
?????文件???????38280??2006-01-17?22:07??workframe\IOCPNet.cpp
?????文件????????8688??2006-01-17?22:06??workframe\IOCPNet.h
?????文件???????11298??2005-08-24?22:45??workframe\linkedListStatic.h
?????文件????????6080??2005-09-10?02:59??workframe\PreAllocator.cpp
?????文件????????1443??2005-08-13?09:40??workframe\PreAllocator.h
?????文件????????1061??2005-08-01?10:32??workframe\SafeDynMem.cpp
?????文件?????????700??2005-07-27?17:00??workframe\SafeDynMem.h
?????文件????????1227??2005-08-01?10:32??workframe\SafeLocker.cpp
?????文件?????????903??2005-07-30?02:48??workframe\SafeLocker.h
?????文件????????2914??2005-08-29?10:43??workframe\SafeStaticMemMulti.cpp
?????文件????????1397??2005-08-13?09:41??workframe\SafeStaticMemMulti.h
?????文件????????9926??2005-08-24?22:49??workframe\TCPFunc.cpp
?????文件?????????764??2005-08-24?22:49??workframe\TCPFunc.h
?????文件?????????175??2005-08-23?14:10??workframe\workframe.h
?????文件????????1230??2005-08-24?22:45??workframe\WorkframeReturnCode.h

評論

共有 條評論