76 lines
1011 B
C++
76 lines
1011 B
C++
#include <winsock.h>
|
|
#include <list>
|
|
using std::list;
|
|
#pragma once
|
|
|
|
|
|
typedef struct NET_TCP_PACKET2
|
|
{
|
|
char* pData;
|
|
int lLen;
|
|
//NET_MANAGER_ENUM enType;
|
|
}*pNET_TCP_PACKET2;
|
|
|
|
|
|
|
|
|
|
typedef unsigned int (*MsgCallBack)(PVOID); //»Øµ÷º¯ÊýÖ¸Õë
|
|
|
|
class CTcpClient
|
|
{
|
|
|
|
public:
|
|
|
|
friend unsigned int __stdcall recvThread(LPVOID param);
|
|
|
|
|
|
public:
|
|
|
|
static void UnInit();
|
|
|
|
BOOL ConnectServer();
|
|
|
|
int StopConnect();
|
|
|
|
int ReConnect();
|
|
|
|
BOOL IsConnect(){return NULL!=m_socket;}
|
|
|
|
void RegisterHwnd(HWND hWnd, PVOID pParent);
|
|
|
|
int SendData(char* pData, int lLen);
|
|
|
|
void PostMessage2MainWnd(UINT uMsg, WPARAM wParam, CString strMsg);
|
|
|
|
|
|
int InitNetInfo(CString strConfName);
|
|
int InitNetInfo(CString strIp, int nPort);
|
|
void HandleNdcCMsg();
|
|
char m_achSendBuf[1024];
|
|
|
|
~CTcpClient(void);
|
|
|
|
time_t m_lLastNetTime;
|
|
time_t m_lLastConnectTime;
|
|
|
|
public:
|
|
CTcpClient();
|
|
|
|
SOCKET m_socket;
|
|
|
|
CString m_strServerIp;
|
|
short m_sPort;
|
|
|
|
HANDLE m_hReceive;
|
|
BOOL m_bStart;
|
|
|
|
public:
|
|
PVOID m_pParent;
|
|
HWND m_hWnd;
|
|
|
|
|
|
|
|
};
|
|
|
|
|