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


#pragma once 
#include "SocketOverlap.h" 
 
 
#define UM_SHOW_MSG   WM_USER+2 
 
class CIOCPServerPackage 
{ 
public: 
	//CIOCPServerPackage(); 
	CIOCPServerPackage(CWnd* pParent); 
public: 
	~CIOCPServerPackage(void); 
 
	CList<CSocketOverlap*, CSocketOverlap*>m_lstSocketOlp;//定义链表 
 
	BOOL m_bInitWinSockFlag; 
 
	CString m_strErrorMsg; 
 
	SOCKET m_socketListen; 
 
	LONG m_nThreadNum; 
 
	HANDLE m_hCompletePort; 
 
	CWnd* m_pParent; 
 
protected: 
	//内部用的的函数,自我调用 
	//服务的线程 
	static DWORD WINAPI ThreadWorking(LPVOID lpVoid); 
	//加载WinSock库 
	BOOL InitWinSock(); 
	//关闭 
	void CloseSocket(); 
	//发送消息 
	BOOL SendMsg(CString strMsg); 
public: 
	//主要的功能:接口,给使用者来用的 
	//启动服务器 
	BOOL StartServer(UINT nListenPort); 
	//停止服务器 
	BOOL StopServer(); 
	//投递请求:Accept 
	BOOL PostAccept(); 
	//投递请求:Recv 
	BOOL PostRecv(CSocketOverlap* pItem); 
	//发送数据 
	BOOL SendData(char *pSendData, DWORD dwDataSize); 
	//得到错误信息 
	CString GetLastErrorMsg() 
	{ 
		return m_strErrorMsg; 
	} 
	 
 
 
};