BOOL InitTCPServer(unsigned short nPort) { for(int i=0; i<sizeof(g_csClients)/sizeof(g_csClients[0]); i++) { InitializeCriticalSectionAndSpinCount(&g_csClients[i], 0x80000400); } mem_pool = AllocIoBufferPool(MAX_UP_LEN, 2048, MAX_DOWN_LEN, 1024); if(!mem_pool) { return(FALSE); } SOCKADDR_IN sain; ZeroMemory(&sain, sizeof(sain)); sain.sin_family = AF_INET; sain.sin_port = htons(nPort); TCP_EP_HANDLER conn_handler = { OnUserConnect, OnUserDisconnect, OnUserData, NULL }; TCP_OPTION tcpopt; GetDefTCPOpt(&tcpopt); tcpopt.sndbuf = 0; tcpopt.reuse_addr = TRUE; tcpopt.keep_alive = TRUE; tcpopt.nodelay = TRUE; end_point = RegisterTcpEndPoint(&sain, &conn_handler, &tcpopt, mem_pool, NULL); return(end_point!=NULL); }
CAsyncIOInit() { ASockIOInit(); ZION_ASSERT(!m_workers); ZION_ASSERT(!m_iopool); m_workers = CreateWorkers(1); m_iopool = AllocIoBufferPool(1024, 1024, 0, 0); }