📄 lansocket.h
字号:
#if !defined(AFX_LANSOCKET_H__BE193A5E_EA95_4B2F_8A0C_2E349098DD67__INCLUDED_)
#define AFX_LANSOCKET_H__BE193A5E_EA95_4B2F_8A0C_2E349098DD67__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LanSocket.h : header file
//
#define CLIENTREAD 0
#define CLIENTSEND 1
#define CONNECT 2
#define SERVERCLOSE 3
#define SERVERREAD 4
#define SERVERSEND 5
#define ACCEPT 6
#define CLIENTCLOSE 7
/////////////////////////////////////////////////////////////////////////////
// CLanSocket command target
class CLanSocket : public CAsyncSocket
{
// Attributes
public:
// Operations
public:
CLanSocket();
virtual ~CLanSocket();
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLanSocket)
public:
virtual void OnSend(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnReceive(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CLanSocket)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
CWnd * m_pWnd;
UINT m_UserMsg;
char m_szBuffer[4096]; //消息缓冲区
CString m_MessStr;
public:
void SetMessagePara(CWnd* pParent,UINT m_nMessageID);
CString GetMessStr(void);
BOOL SendStr(CString m_str);
BOOL m_bAccept;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LANSOCKET_H__BE193A5E_EA95_4B2F_8A0C_2E349098DD67__INCLUDED_)
/////////////////////////////////////////////////////////////////////////////
// CLanSocketServer command target
class CLanSocketServer : public CAsyncSocket
{
// Attributes
public:
// Operations
public:
CLanSocketServer();
virtual ~CLanSocketServer();
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLanSocketServer)
public:
virtual void OnAccept(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CLanSocketServer)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
public:
void CloseServer(void);
void SetMessagePara(CWnd* pParent,UINT m_nMessageID);
CString GetMessStr(void);
BOOL SendStr(CString m_str);
protected:
CWnd *m_pWnd;
UINT m_UserMsg;
CLanSocket *m_pSocket;
CString m_MessStr;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CLanSocketClient command target
class CLanSocketClient : public CAsyncSocket
{
// Attributes
public:
// Operations
public:
CLanSocketClient();
virtual ~CLanSocketClient();
// Overrides
public:
void SetMessagePara(CWnd* pParent,UINT m_nMessageID);
void Rest(void);
CString GetMessStr(void);
BOOL SendStr(CString m_str);
BOOL IsConnect(void);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLanSocketClient)
public:
virtual void OnConnect(int nErrorCode);
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
virtual void OnClose(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CLanSocketClient)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
CWnd * m_pWnd;
UINT m_UserMsg;
BOOL m_bConnected; //是否连接
char m_szBuffer[4096]; //消息缓冲区
CString m_MessStr;
};
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -