华南理工大学用Java开发的FTP服务器_英文_

服务器英文  时间:2021-05-05  阅读:()

华南理工大学学报(自然科学版)

第29卷第8期 Journal of South China Universityof Technology Vol 29 N2o00812001年8月 (Natural Science Edition) August

Article ID: 1000- 565X(2001)08 - 0065 - 05A FTP Server Developed byJava

WanJiang-ping Huang Zhuo-ming Xia Zhi-zhong Zhang Peng

(College of Electronics&Information Eng , South China Univ of Tech , Guangzhou 510640, China)Abstract : In this paper , a FTP server prototyping system is developedbyJava based onthe analysis ofFile Transfer Protocol Implementation model and main class functions are explainedandthe imple2mentation for multi-threads and NVT(network virtual terminal) etc are discussed Finally, a solutionfor FTPproxy server is put forward

Key words : File Transfer Protocol ; Java; socket ; thread; network virtual terminal ; proxy server

CLC number : TP 31 1 52 Document code:A

0 Introduction WIN95/NT

The Java, developed bySun Microsystems , is 1 Concepts of FTP Model

FTP commands are generated bythe user-PI and destination host , the IP address andthe portpro2transmitted to the server process via the control videunique andaccurate exactlyidentificationforcconnection (The user mayestablisha direct con2 onnection between two machines The connec2titrol connection to the server-FTP and generate on is called socket A pair of sockets identifiesestandard FTP commands independently, while veryport connection: (1) sender socket=sourcebypassingthe user-FTPprocess) Standardreplies IP address +source port ; (2) receiver socket =are sent fromthe server-PI to the user-PI over the destination IPaddress+destinationportcontrol connectioninresponse to the commands Client sockets basedonconnectionareimple2

The FTP commands specify the parameters mented bysocket class andareusedtodevelop ap2for the data connection (data port , transfer plication which uses services provided by the ser-mode, representation type, and structure) and ver We can networkprogrambyjava netpacketthe nature of file system operation (store , re2 socket functions in APIs of Java Socket classtrieve, append, delete, etc ) User-DTP“ (Data” methods are listed in Table 1 , where getInput2Transter Prcess ) or its designate should listen Stream andohn thde specified daitaportd, adndthe serfveriinitiates2 for theyareusedtocommunicate to remotehostst e ata connect on an ata trans er n accor Table 1 Socket classmethods

notedthat the data port need not be in the same

receiving OutputStream Return OutputStream con2

The protocol requires the control connections getOutputStream() nectedthe socket

of the control connections when having finished ServerSocket class implements TCPserver’ susingthe FTP service,while it is the server who socket It provides two constructors which speci’2takes the action Theservermayabort data trans2 fies the server socket port to listen to a client sfer if the control connections are closed without connection request Its Accept () method enablescommand the server socket to listenandwaituntil the con2

The Relationship betweenFTPandTelnet is : nection is established When the connection isFTPuses Telnet protocol on the control connec2 done, it returns to a socket class instance whichtion This canbe achievedintwoways : first , the provides service for the clientuser-PI or the server-PI mayimplement the rules 2 2 FTPCommandsof the Telnetprotocol directlyintheir ownproce2 Common FTPcommands are:USER, PASS,dures; or , second, the user-PI or the server-PI CDUP, CDW, QUIT, PORT, TYPE, RETR,maymakeuse of the existing Telnet module inthe STOR, DELE,RMD,MKD,PWD,LIST,NLST,system NOOP etc We have implementedMINIMUM2 A FTP Server Devel2 1 JavaNetwork Programming fer to Reference [6] for the commands specifica2

When data arrive at the networklayer inthe tion

No 8 WanJiang-ping et al :AFTPServerDeveloped byJava 67

2 3 Development of the FTP Server The mainclass provides entryandthe server class2 3 1 FTPServer ImplementationModel listens to the connection and provides multi-users

FTP server addresses multi-users login at login, the ftpThreadis the core andprovides FTPsame time by thread There is a main thread in services, the NVT I/O classes deal with com2the FTPserver to listen to the client connection mands and messages between the clients and theWhenthe client connects to FTP server,A new serverthreadis createdfor it andcontrol is passedtothet There are two important methods in thehread which provides service for client It isn ftpThreadclass :ecessaryto convert NVT(NetworkVirtual Ter2 The run ( ) provides methods in which theminal) I/O to command or replying characters thread’ subclass must be overrided, initiateswhich is processed by program, the connectionc socket s input and output streams and executesontrol command and the reply should be com-p servicesproviding byftp()method, finallyclosesliantwiththe Telnetprotocol Finally, therearedi the connectedsocketsrectoryfunctions , file input and output , trans2 The ftp() interacts with clients, receivesmission parameters setting and user login etc commands and executes operations, and returnFigure 2is the FTPserver implementationmodel acknowledges

invokes run() method We demonstrate it using

Fig 2 FIP server implementation model the ftpThread class as follows :

According to themodel , the FTPserver con2sists of five classes : the mainclass providingpro2 c,

which is the core of FTP server to provide the NVTOutputStream out ;/ /output control streamFTP services , and the NVT I/O classes dealing NVTInputStreamin;//input control streamwith commands and replybetweenclients andthe static final int START=0;server //constant control start

There are five classes in the server program static final int FINISHED=1 ;

/ /constant control end public NVTInputStream(InputStream inStream,String hostName; / /Local host name OutputStream outStream)

Socket client ; //connection socket //ConstructorftpThread(Socket clnt ,String hn) { super(inStream) ; out=OutStream; }

/ /Accepts socket andlocal host name public int read() throws IOExceptionpublic void run() / / identify control codes

//invokes whenftpTreadinstance public String readLine() throws IOException / /{try Readinone line

{/ / Initialize control stream input and output }out=newNVTOutputStream(client getOut2 This class is designed for getting commandsputStream() ) ; from NVTInputStream It discards NVTcontrolin=new NVTInputStream(client getInput2 characters to getpure commands streamforserver

Stream() , out) ; in order to process commands which come fromftp() ;// Interprets FTP commands , re2 customerssponds to data connectionandtransfers data NVT OutputStream Class which correspondsclient close() ; to NVT InputStream is used to write NVT Out2

/ /Service is over, close user connection putStream into FTPclient acknowledge string

} //miss catch IOException for size limit 3 Conclusions

}

2 3 3 Network Virtual Terminal The FTPfunctionis still one of the most im2

Because the FTP controlling connection is portant Internet applications There are manybasedonthe Telnet protocol , theTelnetprotocol problems worth researching such as FTP proxysmust support NVTfor input and output device erver, security (e g combining with directorysThe FTP server should deal with NVT,which is ervice) and its applications (e g completelyim2an abstract device composed of printer and key2 plementing FTPcommands) It canhelp us toun2board Theuser input characters arepassedtothe derstandclient/server interaction in Internet andFTPserver, which returns the result to the user develop the FTP server using Java and be inte2by NVT printer output Carrier return combines gratedinto realworld applications The followingwith new line to terminate NTV control opera2 is a FTPproxyserver solution:tionswhichsupport interruptionanddiscardextra A FTPproxyserver connectionsessioncanbeoutterpret as Command) codewhich is a byte or two pandmore bytes following255 or0xff toindicate a

their implementation byJava :cknowledge and necessary data transferring areeclassNVTInputStreamextends FilterInputStream xecuted among the FTP client , the proxyservera{byte IAC = (byte) 0xff, DO = (byte) 0xfd, nd the FTP server; (5) the FTP client processclWILL=(byte)0xfb, CR=13,LF=10; oses the connection with FTP server; (6) theprint WONT = 252, DONT = 254, BUFFER- oxyserver closes the connectionwith the FTPserSIZE=1024, numBytes=0; ver

OutputStream out; It must be notedthat a FTPproxyis executedbyte lineBuffer =new byteBUFFER-SIZE; at awell-knownport andiswaitingfor client con2

No 8 WanJiang-ping et al :AFTPServerDeveloped byJava 69

nection, and FTPclient process is connectedwith owns independent thread

FTP proxy server correspondingly Therefore a

TCP connection is being built The control con2:nection keeps active during whole FTP process [ 1 ] Comer D E Computer Network and Internet MThe proxy protocol may include a series requests 2nd edition NewJersey:Prentice-Hall ,1999such as identity verifying, access controlling etc [2] Naik D C Internet Standard and Protocols M Wash 2If the connection request is allowed, the FTP ington:Microsoft Press ,1998proxyserver accepts the connection and requests

rewrites and filters the results , then sends the re2 [5] Postel J , Reynolds J Rfc959 File Transfer Protocolsults to the client process EB/OL htt p:/ /ds internic net/ rfc/ rfc959 txt ,1999-

There are three keypoints in system design: 1 1 - 07

(1) to sustain listening; (2) to build many bi-di2 [6] Thomas M D, Patel P,HudsonAD, et al Java Pro2rectional connections ; (3) every client process gramming for the Internet M North Carolina:

Ventana Communication Group Inc, 1997

用Java开发的FTP服务器

万江平 黄卓明 夏志忠 张 鹏

(华南理工大学电子与信息学院,广东广州510640)

摘 要:在分析FTP协议的基础上,用Java开发了一个FTP服务器原型系统,说明了其实现模型及各个类的功能,并讨论了多线程及虚拟网络终端等若干实现问题,最后给出了一种FTP代理服务器的解决方案关键词:文件传输协议; Java;套接字;线程;虚拟网络终端;代理服务器

中图分类号: TP31 1 52 文献标识码:A

文章编号: 1000- 565X(2001)08 - 0065 - 05

收稿日期: 1999- 12- 07

作者简介:万江平(1964) ,男,副教授,博士生,主要从事因特网应用信、息技术管理和复杂性科学的研究

iON Cloud:新加坡cn2 gia vps/1核/2G内存/25G SSD/250G流量/10M带宽,$35/月

iON Cloud怎么样?iON Cloud升级了新加坡CN2 VPS的带宽和流量最低配的原先带宽5M现在升级为10M,流量也从原先的150G升级为250G。注意,流量也仅计算出站方向。iON Cloud是Krypt旗下的云服务器品牌,成立于2019年,是美国老牌机房(1998~)krypt旗下的VPS云服务器品牌,主打国外VPS云服务器业务,均采用KVM架构,整体性能配置较高,云服务器产品质量靠...

ZJI:台湾CN2/香港高主频服务器7折每月595元起,其他全场8折

ZJI原名维翔主机,是原来Wordpress圈知名主机商家,成立于2011年,2018年9月更名为ZJI,提供香港、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册业务。ZJI今年全新上架了台湾CN2线路服务器,本月针对香港高主频服务器和台湾CN2服务器提供7折优惠码,其他机房及产品提供8折优惠码,优惠后台湾CN2线路E5服务器月付595元起。台湾一型CPU:Inte...

提速啦(69元起)香港大带宽CN2+BGP独享云服务器

香港大带宽服务器香港大带宽云服务器目前市场上可以选择的商家十分少,这次给大家推荐的是我们的老便宜提速啦的香港大带宽云服务器,默认通用BGP线路(即CN2+BGP)是由三网直连线路 中国电信骨干网以及HGC、NTT、PCCW等国际线路混合而成的高品质带宽(精品带宽)线路,可有效覆盖全球200多个国家和地区。(适用于绝大部分应用场景,适合国内外访客访问,域名无需备案)提速啦官网链接:点击进入香港Cer...

服务器英文为你推荐
重要产品信息指南支持ipad勒索病毒win7补丁我的电脑是windows7系统,为什么打不了针对勒索病毒的补丁(杀毒软件显用itunes备份iphone怎么从itunes备份恢复谷歌sbgoogle一下"SB",虽然显示的是baidu排第一,链接的不是baidu.micromediawww.macromedia.com 是什么网站迅雷下载速度迅雷下载速度真是太慢了win7还原系统电脑怎么恢复出厂设置win7旗舰版routeaddRout add -p在网络中是什么意思?Route add Cp又是什么意思?chrome18CHROME现在最新版是多少?
域名服务器的作用 免费申请域名和空间 vir 荷兰服务器 狗爹 vultr美国与日本 正版win8.1升级win10 网页背景图片 panel1 新天域互联 亚马逊香港官网 linux使用教程 中国电信宽带测速器 drupal安装 学生服务器 免费php空间 美国主机侦探 phpwind论坛 hosts文件修改 美国vpn服务器 更多