www.pudn.com > ChatRoom.zip > IOServerPackage.h, change:2011-08-02,size:958b


#pragma once 
#include "SocketOverlap.h" 
#define UM_SHOW_MSG		WM_USER+1 
 
class CIOServerPackage 
{ 
public: 
	CIOServerPackage(CWnd* pParent); 
	~CIOServerPackage(void); 
protected: 
	CSocketOverlap m_arySocketOlps[WSA_MAXIMUM_WAIT_EVENTS]; 
 
	WSAEVENT m_aryEvents[WSA_MAXIMUM_WAIT_EVENTS]; 
 
	BOOL m_bInitWinSockFlag; 
 
	CString m_strErrorMsg; 
 
	SOCKET m_socketListen; 
 
	HANDLE m_hStopThreadEvent; 
	HANDLE m_hThreadEndedEvent; 
 
	CWinThread* m_pThreadWorking; 
 
	int m_nSocketNum; 
 
	CWnd* m_pParent; 
 
protected: 
	void Close(); 
	void FreeCSocketOlpItem(CSocketOverlap* pItem); 
 
	BOOL InitWinSock(); 
	BOOL PostAccept(); 
	BOOL PostRecv(CSocketOverlap* pItem); 
	BOOL SendMsg(CString strMsg); 
 
	static UINT ThreadWorking(LPVOID lpVoid); 
 
public: 
	BOOL StartServer(int nPortNum); 
	BOOL StopServer(); 
	// 
	BOOL SendData(char *pSendData, DWORD dwDataSize); 
 
	CString GetLastErrorMsg() 
	{ 
		return m_strErrorMsg; 
	} 
};