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

📄 searchserver.h

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 H
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

// SearchServer.h: interface for the CSearchServer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SEARCHSERVER_H__59ED8180_6266_11D3_B8DD_00600838CD5F__INCLUDED_)
#define AFX_SEARCHSERVER_H__59ED8180_6266_11D3_B8DD_00600838CD5F__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define SEARCH_MAXHOPS                             5
#define REQUEST_STRING_LEN                         150

typedef struct
{
	int nType;
	int nHops;
	char tczStart[4];              // Binary IP representation.
	int nID;
} RequestHeader;

typedef struct
{
	int nResults;
	TCHAR tczMyName[200];
} ResultHeader;

typedef struct
{
	char tczIP[4];
	int nID;
	void *pNext;
} SearchRecord;

class CSearchServer  
{
public:
	BOOL Stop(BOOL bWait);
	BOOL Start();
	CSearchServer(CSecurityFilter *pFilter);
	virtual ~CSearchServer();

protected:
	BOOL FromMe(RequestHeader rHeader);
	BOOL SendRequest(RequestHeader rHeader, LPCTSTR czReqString);
	void CloseConnection(CTimeoutSocket *sock);
	BOOL DeleteLastItem();
	BOOL CutOutRecord(SearchRecord *pRecord);
	SearchRecord * FindRecord(char cIP[4]);
	int FreeRecords();
	BOOL AllocateRecords(int nRecords);
	SearchRecord * m_pRecords;
	BOOL RegisterSearch(char cIP[4], int nID);
	BOOL ReturnResults(RequestHeader reqHeader, CStringArray &csaResults,
		CStringArray &csaTitles);
	BOOL m_bStayOn;

	BOOL GetRequest(CTimeoutSocket *sock, RequestHeader &rReqHeader,
		CString &cszReqString);
	static UINT PASCAL DriveWork(LPVOID *Param);

	bool IP_ExplicitToByte(CString &exprep, unsigned char *brep);
	bool IP_ByteToExplicit(unsigned char *brep, CString &exprep);

	CTimeoutSocket *OpenConnection(LPCTSTR czIP, 
		UINT nPort = PORT_OSCARSEARCHRESULT);

private:
	BOOL AppendComment(LPCTSTR czComment);
	CSecureFileSystem * m_pFileSystem;
	CSecurityFilter * m_pFilter;
};

#endif // !defined(AFX_SEARCHSERVER_H__59ED8180_6266_11D3_B8DD_00600838CD5F__INCLUDED_)

⌨️ 快捷键说明

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