【正文】
pExDelete()。//獲取登錄服務(wù)器IP strSerName=inet_ntoa()。}10. FindNonBlockIP(CString IP)函數(shù)。 i++。 //更新編輯結(jié)果顯示 Update_Data_IP(1)。安全模塊調(diào)用NonBlock_Add_IP ()添加用戶想要允許登錄服務(wù)器的登錄用戶IP。 CAddIPDlg sheep_dlg_SBsa。}2. OnDestroy()函數(shù)。 if (lpHost != NULL) { //循環(huán)提取IP for(int k=0。函數(shù)實(shí)現(xiàn)代碼如下:BOOL CFTP_Security_Child::OnInitDialog() { CDialogResize::OnInitDialog()。Statistics_info_Display)。 //向統(tǒng)計(jì)信息顯示List控件中名稱列元素添加第2個(gè)下載文件總量值 if(((CListCtrl*)GetDlgItem(IDC_STATISTICS))InsertItem(2, 下載文件總量)==1) AfxMessageBox(添加元素失敗)。 (!AfxGetApp()WriteProfileInt(FTPSer, AutoActivate, Auto_Activate)) ) AfxMessageBox(服務(wù)器啟動(dòng)方式配置失敗)。 sscanf(str_user_Time,%d,amp。ClearLog ()函數(shù)為程序設(shè)置模塊的日志文件清空函數(shù)。 else Auto_Activate=FALSE。 int port,user_Num,user_Time。 CString my_strThreadID。 (%d, nID)。 在線用戶模塊設(shè)計(jì)流程圖Fig. Online user modular design flow chart。LVS_EX_GRIDLINES 表示添加表格線。}3. OnSize(UINT nType, int cx, int cy)函數(shù)。 p_Log_Level_sheep = n。上傳文件模塊。服務(wù)器日志模塊的主要功能為顯示和記錄用戶的登錄信息和一系列的操作信息。 17).CRect矩形,就是(left,top,right,bottom)。 6).CWinApp應(yīng)用程序類。一個(gè)例外是菜單(CMenu)不是從窗口派生 的。 C++開發(fā)應(yīng)用程序的過程中,系統(tǒng)為我們生成了大量的各種類型的文件。 Standard模式 FTP的客戶端發(fā)送 PORT 命令到FTPserver。實(shí)際上,幾乎所有類型的信息,所有類型的計(jì)算機(jī)程序都可 以在Internet上找到。 值得注意的是,匿名FTP不適用于所有Internet主機(jī),它只適用于那些提供了這項(xiàng)服務(wù)的主機(jī)。系統(tǒng)管理員建立了一個(gè)特殊的用戶ID,名為anonymous, Internet上的任何人在任何地方都可使用該用戶ID。中國(guó)Web技術(shù)站b:\Qq5xu。關(guān)鍵詞 FTP 服務(wù)器 客戶端 VC++The design of FTP Server and ClientAbstract FTP is a mainstream network file transfer protocol. Design and Implementation of FTP services and clients will help indepth understanding of network programming and FTP, and make the theoretical knowledge and practice together. In this paper, using VC + + programming tool, the FTP server and client designe are designed and implemented. The main design work is for: the design of server and client . Serverside design modules are: server logs module, online modules, procedures set module, statistics module, the security module. Server logs showing module is responsible for the various log information, online displaying is module responsible for online information, procedures setting module is responsible for the allocation of server operating parameters, statistics module is responsible for all the statistical work, security module is responsible for the management of user access privileges. Client design modules are: connect to server module, upload module, download files module. The module to connect to server is responsible for accessing servers by the information which the user enter, uploading file module is responsible for uploading the local paper to the server, downloading files module is responsible for downloading the documents to the local machine from server. Through practical application and testing, it verifys the correctness of the design of the paper.Keywords FTP Sever Client VC++目 錄第1章 引言 1 FTP介紹 1 4 本文工作內(nèi)容 6第2章 系統(tǒng)整體設(shè)計(jì) 7 FTP服務(wù)器整體設(shè)計(jì) 7 FTP客戶端整體設(shè)計(jì) 8第3章 FTP服務(wù)器模塊設(shè)計(jì) 9 9 在線用戶模塊 12 程序設(shè)置模塊 16 統(tǒng)計(jì)模塊 20 安全模塊 24第4章 FTP客戶端模塊設(shè)計(jì) 33 33 下載文件模塊 35 上傳文件模塊 40第5章 結(jié)論和展望 44致 謝 45參考文獻(xiàn) 4651第1章 引言 FTP介紹FTP的主要作用,就是讓用戶連接上一個(gè)遠(yuǎn)程計(jì)算機(jī)(這些計(jì)算機(jī)上運(yùn)行著FTP服務(wù)器程序)察看遠(yuǎn)程計(jì)算機(jī)有哪些文件,然后把文件從遠(yuǎn)程計(jì)算機(jī)上拷到本地計(jì)算機(jī),或把本地計(jì)算機(jī)的文件送到遠(yuǎn)程計(jì)算機(jī)去??蛻舳嗽O(shè)計(jì)模塊主要有:連接服務(wù)器模塊,上傳文件模塊,下載文件模塊。用戶通過客戶機(jī)程序向服務(wù)器程序發(fā)出命令,服務(wù)器程序執(zhí)行用戶所發(fā)出的命令,并將執(zhí)行的結(jié)果返回到客戶機(jī)。rF/E`$D 作為一個(gè)Internet用戶,可通過FTP在任何兩臺(tái)Internet主機(jī)之間拷貝文件。Internet中的有數(shù)目巨大的匿名FTP主機(jī)以及更多的文件,那么到底怎樣才能知道某一 特定文件位于哪個(gè)匿名FTP主機(jī)上的那個(gè)目錄中呢?這正是Archie服務(wù)器所要完成的工作。Visual由于MFC編程方法充分利用了面向?qū)ο蠹夹g(shù)的優(yōu)點(diǎn),它使得我們編程時(shí)極少需要關(guān)心對(duì)象方法的實(shí)現(xiàn)細(xì)節(jié),同時(shí)類庫中的各種對(duì)象的強(qiáng)大功能足以完成我們程序中的絕大部分所需功能,這使得應(yīng)用程序中程序員所需要編寫的代碼大為減少,有力地保證了程序的良好的可調(diào)試性。把CDC想象成一張紙,每個(gè)窗口都有一個(gè)CDC相聯(lián)系,負(fù)責(zé)畫窗口。 15).CString字符串。客戶端設(shè)計(jì)模塊包括:連接服務(wù)器模塊,上傳文件模塊,下載文件模塊。 FTP客戶端整體設(shè)計(jì)客戶端設(shè)計(jì)模塊包括:連接服務(wù)器模塊,上傳文件模塊,下載文件模塊。 //增添新元素,創(chuàng)建新到來的日志顯示消息 CLogMsg *p_Log = new CLogMsg。 else ((CColorListBox*)GetDlgItem(IDC_TRACE)) AddString(pLog_sheep_Text_sheep, RGB(0,0,255))。DWORD SetExtendedStyle(DWORD dwNewStyle);其中6)設(shè)置元素值操作。User_Add_sheep函數(shù)為在線用戶信息顯示List控件,增加元素函數(shù)。Delete_User_sheep函數(shù)為在線用戶信息顯示List控件,刪除元素函數(shù)。函數(shù)為程序設(shè)置模塊銷毀函數(shù)。 if(((CButton*)GetDlgItem(IDC_START_IN_TRAY))GetCheck() ==BST_CHECKED) Start_InTray=TRUE。函數(shù)實(shí)現(xiàn)代碼如下:void CFTP_Configuration_Child::sheep_View() { //打開日志文件 int ExecStatus = (UINT)ShellExecute(m_hWnd, open, , (LPCTSTR), 0, SW_SHOW)。 sscanf(str_user_Num,%d,amp。amp。 //向統(tǒng)計(jì)信息顯示List控件中值列元素添加第0個(gè)初始0值 if(((CListCtrl*)GetDlgItem(IDC_STATISTICS))SetItemText(0, 1, 0)==1) AfxMessageBox(添加元素失敗)。 dwStyle |= LVS_EX_FULLROWSELECT。 安全模塊設(shè)計(jì)流程圖Fig. Security module design flow chart。 struct sockaddr_in sheep_sock。 GetDlgItem(IDC_REMOVE_BLOCK)EnableWindow(!Block_All_FLAG)。安全模塊調(diào)用Edit_Block_IP ()修改用戶想要阻止的登錄用戶IP。 (0)。 if (() == IDOK) {//編輯完畢 if(FindNonBlockIP()) { //修改編輯的IP (IP_index)。 CString Text。 if ((IP) == 0) { // 輸入IP已經(jīng)在安全配置中存在。//讀取用戶輸入登錄服務(wù)器信息 DWORD dwIP=0。 } catch(CInternetException *pEx) {//登錄失敗 TCHAR szError[1024]。 } else return FALSE。//獲取連接服務(wù)器端口 if((strSerName,m_UserName,m_Password,Port))//嘗試連接 {//連接成功 m_Rec+=接入服務(wù)器成功。 i ()。 if(Type!=0) {//更新允許用戶接入IP安全配置IP數(shù)據(jù) while(i ()) { (i, Text)。安全模塊調(diào)用Remove_Nonblock_IP ()移出用戶想要允許登錄服務(wù)器的登錄用戶IP。 (IP_index)。 if (() == IDOK) { //編輯完畢 if(FindBlockIP()) { //編輯修改IP不存在當(dāng)前配置中,修改原編輯IP (IP_index)。//讀取安全配置數(shù)據(jù) AfxGetApp()WriteProfileInt(FTPSer, BlockAll, Block_All_FLAG)。(), lpHosth_addr_list[k], lpHosth_length)。 UpdateData(FALSE)。當(dāng)服務(wù)器的信息發(fā)生改變時(shí),主程序通知統(tǒng)計(jì)模塊,統(tǒng)計(jì)模塊調(diào)用Statistics_info_setValue程序更新統(tǒng)計(jì)信息。 //向統(tǒng)計(jì)信息顯示List控件中值列元素添加第3個(gè)初始0值 if(((CListCtrl*)GetDlgItem(IDC_STATISTICS))SetItemText(3, 1, 0)==1) AfxMessageBox(添加元素失敗)。其統(tǒng)計(jì)參數(shù)有:總連接用戶數(shù),當(dāng)前在線用戶數(shù),文件下載數(shù),文件上傳數(shù),文件下載失敗數(shù),文件上傳失敗數(shù),下載文件總量,上傳文件總量。 if(((CButton*)GetDlgItem(IDC_LAUNCH_ON_STARTUP))GetCheck() ==BST_CHECKED) Launch_On=TRUE。 }4. Configure_Apply()函數(shù)。 //存儲(chǔ)服務(wù)器用戶連接時(shí)間配置 if(!AfxGetApp()WriteProfileInt(FTPSer, Timeout, user_