📄 tcpclient_ce.h
字号:
// TCPClient_CE.h: interface for the CTCPClient_CE class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TCPCLIENT_CE_H__B7856B99_69E7_4868_9BA3_96152245C65E__INCLUDED_)
#define AFX_TCPCLIENT_CE_H__B7856B99_69E7_4868_9BA3_96152245C65E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <winsock.h>
#include "mod_tcpbase.h"
/*
//定义连接断开事件
typedef void (CALLBACK* ONDISCONNECT)(CWnd*);
//定义当有数据接收事件
typedef void (CALLBACK* ONREAD)(CWnd*,const char * buf,int len );
//定义Socket错误事件
typedef void (CALLBACK* ONERROR)(CWnd*,int nErrorCode);
*/
class CTCPClient_CE
{
public:
CTCPClient_CE(LPCTSTR szIPaddr, UINT nPort, UINT nBuffMax, HWND hWnd,
LPCTSTR initStr, UINT ninitLen);
virtual ~CTCPClient_CE();
public:
//打开客户端socket
bool Open();
//关闭客户端socket
bool Close();
//与服务器端建立连接
bool Connect();
//向服务器端发送数据
bool SendData(const char * buf , int len);
int m_nTimeout;
public:
static LPCTSTR GetErrorString();
bool BeginWriteThread();
void SelfClose();
bool IsDead();
BOOL IsQueueEmpty(UINT nTag);
bool GetSendBuff(char *buf, int *plen);
bool AddSendQueue(const char *buf, int len);
bool GetBuff(char * buf, int * plen);
bool AddBuff(const char * buf, int len);
//写线程退出的信号句柄
HANDLE m_exitWriteEvent;
//窗口句柄
HWND m_hwnd;
//通讯线程退出事件句柄
HANDLE m_exitThreadEvent;
//通讯Socket句柄
SOCKET m_socket;
private:
//远程主机IP地址
CString m_remoteHost;
//远程主机端口
int m_port;
//通讯线程句柄
HANDLE m_tcpThreadHandle;
HANDLE m_tcpWriteHandle;
//数据缓冲区
TcpBuffQueue m_buffqueue; // 接收缓冲区
TcpBuffQueue m_sendQueue; // 发送缓冲区
UINT m_nbuffMax;
//初始化串和串长
char m_initStr[1024];
UINT m_ninitLen;
bool m_bDead;
private:
protected:
};
#endif // !defined(AFX_TCPCLIENT_CE_H__B7856B99_69E7_4868_9BA3_96152245C65E__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -