#ifndef YASERVER_CLIENTSOCKET_H_
#define YASERVER_CLIENTSOCKET_H_

// CClientSocket 命令目标

class CYAServerDlg;

class CClientSocket : public CAsyncSocket
{
	DECLARE_DYNAMIC(CClientSocket);
private:
	CClientSocket(const CClientSocket& rSrc);
	void operator=(const CClientSocket& rSrc);
public:
	CClientSocket(CYAServerDlg* pDlg);
	virtual ~CClientSocket();

	virtual void OnClose(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
public:
	CYAServerDlg* m_pDlg;
	CString rAddress;//IP
	//BOOL bCollServer;//是否采集服务器
	//DATE mReceiveDateTimeSock;
	//int RetryTimes; //重试次数，如果失去连接3次，则认为已经关断。
	//BOOL ReceiveData;//是否接收采集的数据
	DWORD m_wReadLength;
	WORD m_wDataLength;
	WORD m_wCharacterWord;

	BYTE* m_ReceiveBuffer;
	bool bError; //是否出错
	BOOL m_bClosed;
	//BOOL m_bNeedRemallocMem;
	DWORD reader_id;
public:
	void Init();
	void Abort();
	BOOL SendData(WORD wCharacterWord,int wLength,BYTE* DataBuffer);
protected:
	virtual void OnReceive(int nErrorCode);
	virtual void OnSend(int nErrorCode);
};

#endif // YASERVER_CLIENTSOCKET_H_

