diff --git a/TcpClient.h b/TcpClient.h new file mode 100644 index 0000000..f4fb170 --- /dev/null +++ b/TcpClient.h @@ -0,0 +1,74 @@ +#include +#include +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; + + + +}; +