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

friendhosting:(优惠55%)大促销,全场VPS降价55%,9个机房,不限流量

每年的7月的最后一个周五是全球性质的“系统管理员日”,据说是为了感谢系统管理员的辛苦工作....friendhosting决定从现在开始一直到9月8日对其全球9个数据中心的VPS进行4.5折(优惠55%)大促销。所有VPS基于KVM虚拟,给100M带宽,不限制流量,允许自定义上传ISO...官方网站:https://friendhosting.net比特币、信用卡、PayPal、支付宝、微信、we...

提速啦(24元/月)河南BGP云服务器活动 买一年送一年4核 4G 5M

提速啦的来历提速啦是 网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑 由赣州王成璟网络科技有限公司旗下赣州提速啦网络科技有限公司运营 投资1000万人民币 在美国Cera 香港CTG 香港Cera 国内 杭州 宿迁 浙江 赣州 南昌 大连 辽宁 扬州 等地区建立数据中心 正规持有IDC ISP CDN 云牌照 公司。公司购买产品支持3天内退款 超过3天步退款政策。提速啦的市场定位提速啦主...

A2Hosting三年付$1.99/月,庆祝18周年/WordPress共享主机最高优惠81%/100GB SSD空间/无限流量

A2Hosting主机,A2Hosting怎么样?A2Hosting是UK2集团下属公司,成立于2003年的老牌国外主机商,产品包括虚拟主机、VPS和独立服务器等,数据中心提供包括美国、新加坡softlayer和荷兰三个地区机房。A2Hosting在国外是一家非常大非常有名气的终合型主机商,拥有几百万的客户,非常值得信赖,国外主机论坛对它家的虚拟主机评价非常不错,当前,A2Hosting主机庆祝1...

服务器英文为你推荐
支持ipad司机苹果5南京医科大学合同管理系统C1:山东品牌商品馆Applicationsios5netbios端口怎么关闭8909端口!其他端口就不用了重庆电信网速测试电信100M下载速度多少M,为什么我家里电信100M下载速度最快5M美妙,是不是严重缩水win7如何关闭445端口如何彻底永久取消win7粘滞键功能google中国地图求教谷歌中国地图~手机如何使用?win7还原系统电脑怎么恢复出厂设置win7旗舰版
vps优惠码cnyvps cn域名备案 site5 t牌 bluehost 密码泄露 qingyun 1g内存 天翼云盘 搜索引擎提交入口 raid10 重庆电信服务器托管 英雄联盟台服官网 贵阳电信测速 服务器防火墙 注册阿里云邮箱 域名转入 hosting24 ncp ncp是什么 更多