123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #ifndef _CLIENT_SOCKET_H_
- #define _CLIENT_SOCKET_H_
- #include "TcpParse.h"
- #pragma warning(push)
- #pragma warning(disable:4995)
- #pragma warning(pop)
- #include "CritSection.h"
- #include "SocketHandle.h"
- #include "SocketClientImpl.h"
- const int TCPCLIENTNUM = 50;
- class CTCPClient: public CDialog, public ISocketClientHandler
- {
- typedef SocketClientImpl<ISocketClientHandler> CSocketClient;
- friend CSocketClient;
- protected:
- // ISocketServerHandler
- virtual void OnThreadBegin(CSocketHandle* pSH);
- virtual void OnThreadExit(CSocketHandle* pSH);
- virtual void OnDataReceived(CSocketHandle* pSH, const BYTE* pbData, DWORD dwCount, const SockAddrIn& addr);
- virtual void OnConnectionDropped(CSocketHandle* pSH);
- virtual void OnConnectionError(CSocketHandle* pSH, DWORD dwError);
- void GetAddress(const SockAddrIn& addrIn, CString& rString) const;
- bool SetupMCAST();
- public:
- CTCPClient();
- ~CTCPClient();
- BOOL Connection(LPCTSTR strAddr, LPCTSTR strPort);
- void DisConnection(void);
- // 静态成员函数,提供全局访问的接口(给IDE调用)
- static CTCPClient* GetInstancePtr( int iTCPIndex );
- BOOL SendNoticeToServer( int iCmd,int iOperateType,CString sUserName,CString sUID,int iVarID );
- BOOL GetDogInfo();
- BOOL TestAlarm();
- BOOL ConfigAlarm( CString sUID,int iVarID,int iStatus,int iAlarmIndex );
- public :
- CSocketClient m_SocketClient;
- CTcpParse m_TcpParse;
- BOOL m_bSocket;
- void Release();
- private:
- enum { IDD = 10 };
- int m_nSockType; //UDP 或 TCP
- int m_nMode; //IP4 或 IP6
- // CTCPClient数组,在GetInstancePtr里创建成员;
- static CTCPClient *m_pTcpClient[TCPCLIENTNUM];
- };
- #endif
|