monitortcpslave.h
来自「一个通讯管理机的源代码。比较好用。推荐」· C头文件 代码 · 共 62 行
H
62 行
#ifndef _MONITOR_TCP_H#define _MONITOR_TCP_H#include "msystem.h"#include "tinycxx/etc.h"#include "tinycxx/exception.h"#include "tinycxx/socket.h"#include "tinycxx/socksvr.h"class CMonitorTCPSlave : public CNBTcpSvr{public: CMonitorTCPSlave(CAllMgr* pAllMgr,const CInetAddress stInetAddr=CInetAddress("*"), tcport_t tPort=2048) : CNBTcpSvr(stInetAddr, tPort) { m_pAllMgr = pAllMgr; m_hThread = 0; m_dwLast = 0; m_dwPrev = 1; } ~CMonitorTCPSlave() { Shutdown(); } bool Init(); bool IsRun() { bool bRet = true; CTimeVal tv; CTimeValSpan tvs = tv - m_tv; if ((tvs.GetASecs() > 20) && (m_dwLast == m_dwPrev)) bRet = false; if (m_dwLast != m_dwPrev) { m_dwLast = m_dwPrev; m_tv = tv; } return bRet; }protected: DWORD m_dwLast,m_dwPrev; CTimeVal m_tv; void RunSlave();protected: virtual bool OnRead(CTcpStream& stTcpStream); virtual bool OnException(CException& e) { /*cout << e << endl; */return true; } virtual bool OnWrite(CTcpStream& stTcpStream); CAllMgr* m_pAllMgr; int processMsg(unsigned char b[],unsigned len);// map<struReg,struLocal> m_mapReg; pthread_t m_hThread; const static WORD m_wBuffSize; friend void* MonitorTCPSlave(void *pVoid);};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?