开源的socket服务端客户端,支持C# C++

ServerDlg.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // ServerDlg.h : header file
  2. //
  3. #pragma once
  4. #include "afxwin.h"
  5. #include "../../../Src/HPSocket.h"
  6. #include "../../Global/helper.h"
  7. // CServerDlg dialog
  8. class CServerDlg : public CDialogEx, public CTcpServerListener
  9. {
  10. // Construction
  11. public:
  12. CServerDlg(CWnd* pParent = nullptr); // standard constructor
  13. // Dialog Data
  14. enum { IDD = IDD_SERVER_DIALOG };
  15. protected:
  16. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  17. virtual BOOL PreTranslateMessage(MSG* pMsg);
  18. // Implementation
  19. protected:
  20. HICON m_hIcon;
  21. // Generated message map functions
  22. virtual BOOL OnInitDialog();
  23. afx_msg void OnPaint();
  24. afx_msg HCURSOR OnQueryDragIcon();
  25. afx_msg void OnBnClickedStart();
  26. afx_msg void OnBnClickedStop();
  27. afx_msg LRESULT CServerDlg::OnUserInfoMsg(WPARAM wp, LPARAM lp);
  28. afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
  29. afx_msg void OnClose();
  30. DECLARE_MESSAGE_MAP()
  31. public:
  32. void SetAppState(EnAppState state);
  33. void Statistics();
  34. void Reset(BOOL bResetClientCount = TRUE);
  35. private:
  36. virtual EnHandleResult OnPrepareListen(ITcpServer* pSender, SOCKET soListen);
  37. virtual EnHandleResult OnSend(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength);
  38. virtual EnHandleResult OnReceive(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength);
  39. virtual EnHandleResult OnClose(ITcpServer* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
  40. virtual EnHandleResult OnAccept(ITcpServer* pSender, CONNID dwConnID, SOCKET soClient);
  41. virtual EnHandleResult OnShutdown(ITcpServer* pSender);
  42. private:
  43. CListBox m_Info;
  44. CEdit m_Port;
  45. CComboBox m_SendPolicy;
  46. CComboBox m_ThreadCount;
  47. CComboBox m_MaxConnCount;
  48. CButton m_Start;
  49. CButton m_Stop;
  50. EnAppState m_enState;
  51. volatile LONGLONG m_llTotalReceived;
  52. volatile LONGLONG m_llTotalSent;
  53. volatile LONG m_lClientCount;
  54. CCriSec m_cs;
  55. CTcpServerPtr m_Server;
  56. };