123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #pragma once
- #include <afxwin.h>
- #include <atlbase.h>
- #include "SocketHandle.h"
- #include "SocketClientImpl.h"
- #include "head.h"
- class CClientSocket:public CDialog, public ISocketClientHandler
- {
- typedef SocketClientImpl<ISocketClientHandler> CSocketClient;
- friend CSocketClient;
- protected:
- // SocketClient Interface handler
- 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);
- protected:
- private:
- bool GetDestination(SockAddrIn& addrIn) const;
- int ReadDataRes(char *pTmpData);
- int WriteDataRes(char *pData);
- int ReadDataResError(char *pData);
- int WriteDataResError(char *pData);
- public:
- int ClientSend(char* pMsg, int iLen);
- BOOL Connection(LPCTSTR strAddr, LPCTSTR strPort);
- void DisConnection(void);
- bool SetupMCAST();
- void GetAddress(const SockAddrIn& addrIn, CString& rString) const;
- void ProcessData(CSocketHandle *pSH, const BYTE* pData, DWORD nLen);
- int OnCmdProcess(void *pData, int iDataLen);
- static DWORD WINAPI ReConnectSrvThread( void *pData );
- public:
- int WorkMain(REQUESTPARAM SetBasePara);
- int Write(REQUESTWRPARAM writeParam);
- int RequestStatus(void *pData, int nLen);
- public:
- CClientSocket(void);
- ~CClientSocket(void);
- public:
- HANDLE m_hSemNet;
- int m_nSockType; //UDP »ò TCP
- int m_nMode; //IP4 »ò IP6
- BOOL m_bSocket;
- CSocketClient m_SocketClient;
- HANDLE m_hReConnectSrvThread;
- HANDLE m_hRunObject;
- char m_chIpAddr[32];
- int m_nNetPort;
- public:
- RESPONSE_STRUCT m_structResponse;
- WRITESUCCESSRESPONSE m_structWriteResponse;
- };
|