📄 baseserver.h
字号:
#ifndef _ZONESVR_BASESERVER_H_
#define _ZONESVR_BASESERVER_H_
#include <winsock2.h>
#include "defines.h"
#include "LoopThread.h"
class CBaseServer : public CLoopThread
{
public:
BOOL m_bConnect;
SOCKET m_sSocket;
WSAEVENT m_wsaEvent;
WSANETWORKEVENTS m_netEvent;
// recv buffer manage
char m_RecvMsgQBuf[MAX_MSG_Q_BUF];
int m_nRecvStartPos;
int m_nRecvEndPos;
// send buffer manage
char m_SendMsgQBuf[MAX_MSG_Q_BUF];
int m_nSendStartPos;
int m_nSendEndPos;
CRITICAL_SECTION m_csSend;
void Lock() { EnterCriticalSection(&m_csSend); }
void Unlock() { LeaveCriticalSection(&m_csSend); }
public:
CBaseServer();
virtual ~CBaseServer();
BOOL Connect(char * pszAddr, int nPort);
void SetNetEvent();
void SvrProc();
BOOL RecvMsg();
virtual BOOL SendMsg(void * pMsg, int nLen);
virtual void OnClose() {};
virtual void ParseMsg() {};
// Recv Msg Q 包府
int GetSizeInBuf();
BOOL PushMsgQ(void * pMsg, int nLen);
BOOL PopMsgQ(void * pMsg, int nLen);
void * PopMsgQ(int nLen);
// Send Msg Q 包府
int GetSizeInSendBuf();
BOOL PushSendMsgQ(void * pMsg, int nLen);
// Send thread 包府
BOOL InitSendThread();
virtual void LoopProc();
void SendProc();
void CloseSendThread();
//socket buffer resize
int ResizeSNDBUF(const int nSize);
int ResizeRCVBUF(const int nSize);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -