////////////////////////////////////////////////////////////////////////// /// aio functions ////////////////////////////////////////////////////////////////////////// int aio_socket_init(int threads) { WORD wVersionRequested; WSADATA wsaData; wVersionRequested = MAKEWORD(2, 2); WSAStartup(wVersionRequested, &wsaData); iocp_init(); return iocp_create(threads); }
bool CNet::CNetInitialize(const s8 nThreadCount, const s64 lWaitMs) { LogModuleInit(); m_demo = false; m_stop = false; m_nThreadCount = nThreadCount; m_lWaitMs = lWaitMs; NET_TRACE("网络引擎初始化,线程数 %d, 单帧最大时间 %d", nThreadCount, lWaitMs); s32 err; s32 code = iocp_init(lWaitMs, &err); if (code != ERROR_NO_ERROR) { NET_ERROR("init iocp error, last code : %d", err); ASSERT(false); } else { NET_TRACE("init iocp success"); for (s32 i=0; i<nThreadCount; i++) { HANDLE hThread = ::CreateThread(NULL, 0, CNet::NetLoop, (LPVOID)this, 0, NULL); CloseHandle(hThread); } } return true; }