华南理工大学用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) ,男,副教授,博士生,主要从事因特网应用信、息技术管理和复杂性科学的研究

CloudCone(12.95美元/月CN2 GT线路,KVM架构1 Gbps带宽

整理一下CloudCone商家之前推送的闪购VPS云服务器产品,数量有限,活动推出可能很快机器就售罄了,有需要美国便宜VPS云服务器的朋友可以关注一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2017年的美国服务器提供商,国外实力大厂,自己开发的主机系统面板,CloudCone主要销售美国洛杉矶云服务器产品,优势特点是...

艾云年付125元圣何塞GTT,洛杉矶vps年付85元

艾云怎么样?艾云是一家去年年底成立的国人主机商家,商家主要销售基于KVM虚拟架构的VPS服务,机房目前有美国洛杉矶、圣何塞和英国伦敦,目前商家推出了一些年付特价套餐,性价比非常高,洛杉矶套餐低至85元每年,给500M带宽,可解奈飞,另外圣何塞也有特价机器;1核/1G/20G SSD/3T/2.5Gbps,有需要的朋友以入手。点击进入:艾云官方网站艾云vps促销套餐:KVM虚拟架构,自带20G的防御...

美国G口/香港CTG/美国T级超防云/物理机/CDN大促销 1核 1G 24元/月

[六一云迎国庆]转盘活动实物礼品美国G口/香港CTG/美国T级超防云/物理机/CDN大促销六一云 成立于2018年,归属于西安六一网络科技有限公司,是一家国内正规持有IDC ISP CDN IRCS电信经营许可证书的老牌商家。大陆持证公司受大陆各部门监管不好用支持退款退现,再也不怕被割韭菜了!主要业务有:国内高防云,美国高防云,美国cera大带宽,香港CTG,香港沙田CN2,海外站群服务,物理机,...

服务器英文为你推荐
学生微信5爱信艾达株式会社支持ipad支持ipad支持ipad三星苹果5win7关闭445端口如何快速关闭445端口ipad如何上网ipad如何允许app使用网络ipad连不上wifiipad2 wifi连接不上,刚连上就弹出一个 success页面iexplore.exe应用程序错误iexplore.exe - 应用程序错误怎么办阿??????
北京租服务器 qq云存储 分销主机 pw域名 美国php主机 申请空间 湖南服务器托管 创梦 有奖调查 drupal安装 监控服务器 免费的域名 中国域名 深圳域名 阿里云手机官网 免费蓝钻 云销售系统 深圳主机托管 闪讯网 mteam 更多