Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
SockThread.cpp
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Category:
Game Server Simulator
Development Platform:
C/C++
- // SockThread.cpp: implementation of the CSockThread class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "SockThread.h"
- #include "S3Relay.h"
- #include "Global.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CSockThread::CSockThread()
- : m_step(step_NONE), m_cntLoop(0), m_tickLoop(0)
- {
- }
- CSockThread::~CSockThread()
- {
- }
- DWORD CSockThread::Main(LPVOID lpParam)
- {
- try
- {
- DEBUGDO( m_step = step_NONE );
- DEBUGDO( m_tickLoop = 0 );
- DEBUGDO( m_cntLoop = 0 );
- DEBUGDO( m_step = step_EnterLoop);
- EnterLoop();
- while (!IsAskingStop())
- {
- DEBUGDO( m_tickLoop = ::GetTickCount() );
- DEBUGDO( ++ m_cntLoop );
- DEBUGDO( m_step = step_PrepareSock);
- PrepareSock();
- DEBUGDO( m_step = step_RelayCenter);
- g_RelayCenter.Route();
- DEBUGDO( m_step = step_RelayServer);
- g_RelayServer.Route();
- DEBUGDO( m_step = step_RootCenter);
- g_RootCenter.Route();
- DEBUGDO( m_step = step_GatewayCenter);
- g_GatewayCenter.Route();
- DEBUGDO( m_step = step_HostServer);
- g_HostServer.Route();
- DEBUGDO( m_step = step_TongServer);
- g_TongServer.Route();
- DEBUGDO( m_step = step_ChatServer);
- g_ChatServer.Route();
- DEBUGDO( m_step = step_UnprepareSock);
- UnprepareSock();
- DEBUGDO( m_step = step_Sleep);
- ::Sleep(breathe_interval);
- }
- DEBUGDO( m_step = step_LeaveLoop);
- LeaveLoop();
- }
- catch (...)
- {
- rTRACE("fatal: sock thread except");
- }
- return 0;
- }
- HANDLE CSockThread::Start()
- {
- if (m_hProcessor != NULL)
- return m_hProcessor;
- m_step = step_NONE;
- m_cntLoop = 0;
- m_tickLoop = 0;
- HANDLE reth = KThread::Start();
- if (!reth)
- {
- rTRACE("FAIL: SockThread start");
- return NULL;
- }
- rTRACE("SockThread start success");
- return reth;
- }
- BOOL CSockThread::Stop()
- {
- if (!m_hProcessor)
- return TRUE;
- if (!KThread::Stop())
- {
- rTRACE("FAIL: SockThread stop");
- return FALSE;
- }
- m_step = step_NONE;
- m_cntLoop = 0;
- m_tickLoop = 0;
- rTRACE("SockThread stop success");
- return TRUE;
- }
- BOOL CSockThread::TraceInfo()
- {
- static const char* stepdesc[] = {
- "NONE",
- "EnterLoop",
- "PrepareSock",
- "RelayCenter",
- "RelayServer",
- "RootCenter",
- "GatewayCenter",
- "HostServer",
- "TongServer",
- "ChatServer",
- "UnprepareSock",
- "LeaveLoop",
- "Sleep",
- };
- rTRACE("message: [SockThread] tickLoop: %d, cntLoop: %d, step: %s", m_tickLoop, m_cntLoop, stepdesc[m_step]);
- return TRUE;
- }