⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 network.h

📁 墨香最新私服
💻 H
字号:
#ifndef NETWORK_H
#define NETWORK_H

#include "connection.h"
#include "define.h"
#include "create_index.h"

class CNetwork
{
	CIndexCreator*			m_pIndexCreator;
	HWND					m_hProcWnd;
	CConnection**			m_ppConnectionTable;
	WORD					m_wPort;
	DWORD					m_dwConnectionNum;
	DWORD					m_dwMaxConnectionNum;
	SOCKET					m_socketListen;
	sockaddr_in				m_sckadrAdress;
	WORD					m_wSockEventWinMsgID;				// Added by chan78 at 2002/05/28

	void					InitSocket();
	void					ReleaseSocket();
	BOOL					PrepareRead(DWORD	dwIndex);
	DWORD					AddConnection(SOCKET s);

public:
	WORD					GetWinMsgID()						{ return m_wSockEventWinMsgID; };

	void					CloseConnection(DWORD dwIndex);
	void					CloseAllConnection();
    void					(*ReceivedMsg)(DWORD dwInex,char* pMsg,DWORD dwLen);
	void					(*OnDisconnect)(DWORD dwInex);
	void					(*OnConnect)(DWORD dwInex);
	SOCKET					GetListenSocket()					{return m_socketListen;}
	DWORD					GetConnectionIndex(CConnection* pCon) { pCon->GetIndex();}
	WORD					GetPort() {return m_wPort;}
	BOOL					Send(DWORD dwConnectionIndex,char* msg,DWORD length);
	DWORD					ConnectToServer(char* szIP,WORD port);
	BOOL					StartServer(char* ip,WORD port);
	void					CompulsiveDisconnect(DWORD dwIndex);
	CConnection*			GetConnection(DWORD dwConnectionIndex);
	friend	void			SocketEventProc1();

	CNetwork( HWND hWnd,DWORD dwMaxConnectionNum, WORD wSockEventWinMsgID );
	~CNetwork();
};

extern CNetwork* g_pNetwork;


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -