欢迎来到天天文库
浏览记录
ID:46579716
大小:380.50 KB
页数:7页
时间:2019-11-25
《FileZilla客户端实现分析》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、FileZilla客户端实现分析FileZillaClientAnalysisByDavid.Zhu2005/8/2ContentList:•SourceFileClassification•MainFrameworkofFileZillaClient•NetworkImplementationAnalysis•GetNuggetsfromMisc•ExploreFileZillaClientGUI•KnowledgeRepository•Summarize•Reference1.1SourceFileClassificationCommandQueue.cppFil
2、eZilla.cppFileZillaApi.cppFtpListResult.cppKernelMainThread.cppSiteManager.cppDefinition&SFtpCommandIDs.hFzApiStructures.hstructures.hConfigurationAsyncSocketEx.cppAsyncGssSocketLayer.cppAsyncProxySocketLayer.cppNetworkAsyncSocketExLayer.cppAsyncSslSocketLayer.cppControlSocket.cppSubstr
3、ateIdentServerControl.cppIdentServerDataSocket.cppSftpControlSocket.cppFtpControlSocket.cppTransferSocket.cppAsyncRequestQueue.cppFileChangeNotify.cppMFC64bitFix.cppMiscPathFunctions.cppversion.cppApiLog.cppServerPath.cppSFtpIpc.cppSpeedLimit.cppDirectoryCache.cppCrypt.cppGUIRelatedAllo
4、thers.TheyaretoomanyandIdon'twannalistthemhere.1.2MainFrameworkofFileZillaClientFileZilla客户端的GUI核心就是CMainFrame,CMainFrame在创建的时候(CMainFrame::OnCreate)会创建一个CFileZillaApi对象(m_pFileZillaApi)和一个CCommandQueue对象(m_pCommandQueue),FileZilla客户端为其命令通道专门创建了一线程CMainThread,该线程采用Command模式来实现的:GUI部分通过P
5、ostThreadMessage发送FZAPI_THREADMSG_COMMAND消息给CMainThread来完成发送FTP命令,CMainThread将所有的FTP命令封装成一个t_command结构(definedinFileZillaApi.h),通过FZAPI_THREADMSG_COMMAND线程消息来接收GUI发来的FTP命令。CFileZillaApi则在GUI和CMainFrame中充当了一个Proxy的作用,而CCommandQueue则充当着命令缓冲和序列化的作用。在CMainThread中保存了主窗口的HWND和消息ID,在必要的时候CMain
6、Thread就可以通过窗口的消息机制来通知主窗口线程。我们知道在FTP的时候都是走的双通道:一个命令通道;一个数据通道。在FileZilla中命令通道对应的就是CFtpControlSocket,数据通道对应的就是CTransferSocket.在CMainThread初始化的时候(CMainThread::InitInstance),就创建了CFtpControlSocket,在GUI发命令要求连接FTP服务器的时候,其调用Connect去连接远程FTP服务器。数据传输通道的建立则是在通过命令通道发送了LIST命令,FTP服务器返回之后,才创建了CTransferS
7、ocket对象,并将其作为一个Server,调用Listen等待FTP服务器的连接。数据通道主要是接收LIST命令返回的服务器文件树和DOWNLOAD命令传来的下载文件的数据(见CTransferSocket::OnReceive)。FileZilla客户端提供了KeepAlive机制,在CMainThread中设置了一个Timer,如果配置了OPTION_KEEPALIVE选项,系统就会在空闲时向服务器随机的发送PWD,REST0,TYPEA,TYPEI命令,以避免FTP服务器因为客户端连上来后长时间没有动作而自动关闭与客户端的连接。1.3Netw
此文档下载收益归作者所有