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

SugarHosts糖果主机,(67元/年)云服务器/虚拟主机低至半价

SugarHosts 糖果主机商也算是比较老牌的主机商,从2009年开始推出虚拟主机以来,目前当然还是以虚拟主机为主,也有新增云服务器和独立服务器。早年很多网友也比较争议他们家是不是国人商家,其实这些不是特别重要,我们很多国人商家或者国外商家主要还是看重的是品质和服务。一晃十二年过去,有看到SugarHosts糖果主机商12周年的促销活动。如果我们有需要香港、美国、德国虚拟主机的可以选择,他们家的...

Kinponet是谁?Kinponet前身公司叫金宝idc 成立于2013年 开始代理销售美国vps。

在2014年发现原来使用VPS的客户需求慢慢的在改版,VPS已经不能满足客户的需求。我们开始代理机房的独立服务器,主推和HS机房的独立服务器。经过一年多的发展,我们发现代理的服务器配置参差不齐,机房的售后服务也无法完全跟上,导致了很多问题发生,对使用体验带来了很多的不便,很多客户离开了我们。经过我们慎重的考虑和客户的建议。我们在2015开始了重大的改变, 2015年,我们开始计划托管自己...

青云互联:洛杉矶CN2弹性云限时七折,Cera机房三网CN2gia回程,13.3元/月起

青云互联怎么样?青云互联是一家成立于2020年6月份的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,目前提供有美国免费主机、香港主机、香港服务器、美国云服务器,让您的网站高速、稳定运行。目前,美国洛杉矶cn2弹性云限时七折,美国cera机房三网CN2gia回程 13.3元/月起,可选Windows/可自定义配置。点击进入:青云互联官网青云互联优惠码:七折优惠码:dVRKp2tP (续...

服务器英文为你推荐
学生微信5设置xpMax163followcssOPENCORE苹果引导配置说明第四版-基于杭州市西湖区翠苑第四幼儿园智慧校园采购项目支持ipadtracerouteLinux 下traceroute的工作原理是什么 !ipadwifiipad的wifi打不开怎么办?win10445端口Win10系统开放端口号怎样查看?
双线虚拟主机 韩国服务器租用 欧洲欧洲vps 域名备案信息查询 泛域名绑定 lnmp singlehop 息壤主机 linode代购 java主机 缓存服务器 特价空间 wordpress技巧 42u标准机柜尺寸 dd444 40g硬盘 百度云1t 云营销系统 免费的域名 万网空间 更多