请问ftp服务器怎么写(50分)

  • 主题发起人 主题发起人 j810208
  • 开始时间 开始时间
J

j810208

Unregistered / Unconfirmed
GUEST, unregistred user!
请问ftp服务器怎么写,服务器的信息怎么传给ftp的,如端口,服务器地址,有没有ftp的一些原理啊
 
谁用ftpserver写过服务器吗,能不能给我一份,很急!谢谢
 

《计算机世界
出版日期: 20000821
编程实现拨号网络连接及FTP应用

河南煤炭工业厅信息中心 李克利
本文介绍了Windows下如何在程序中加入拨号网络,如何自己编写
程序实现FTP功能。
Windows本身带有拨号网络功能。由于拨号网络不是一个可执行
文件,所以不能用 " WinExec 可执行文件"的方式来打开。要启动拨
号网络,需要用 Explorer ,方法如下:
WinExec(‘Explorer::
{20D04FE0 3AEA 1069 A2D8 08002B30309D}/::
{992CFFA0-F557 101A 88EC 00DD010CCC48}',
SW_SHOWNA);
但若是要启动拨号网络中的某一个连接,则需借助rundll.exe 及
rnaui.dll来启动,方法如下(假定连接名称为MyFtpNet):
WinExec(‘rundll rnaui.dll,RnaDial MyFtpNet',SW_SHOWNA);
这样程序运行到此命令时,将会弹出拨号网络连接MyFtpNet窗口,
输入用户名、密码等信息即可登录,如想更加方便,则可对此连接编写
脚本文件,不需要用户输入任何信息, 使程序自动登录。
在Delphi中具有可用的FTP控件,所以使FTP编程将会变得极其方
便。下面我们对编写FTP应用的Form进行设计:
添加TNMFTP控件:NMFTP1
添加Label控件:Label1、Label2、Label3、Label4、Label5、La
bel6
Label1.Caption = ‘主机名称'
Label2.Caption = ‘主机端口号'
Label3.Caption = ‘用户名'
Label4.Caption = ‘用户口令'
Label5.Caption = ‘代理服务器'
Label6.Caption = ‘代理端口号'
添加Edit控件:HostTxt(FTP主机名)、PortTxt(FTP主机端口)、U
serTxt(用户名)、PassTxt(用户口令)、ProxyServerTxt(代理服务器
地址)、ProxyPortTxt(代理服务器端口)
添加CheckBox控件:CheckBox1CheckBox1.Caption = ‘使用代理
服务器'
添加Button控件:Button1(连FTP主机)、Button2(断开FTP主机)
、Button3(列FTP目录)
Button1.Caption = ‘连接'
Button2.Caption = ‘断开'
Button3.Caption = ‘列目录'
将以上控件以友好界面方式在Form中进行放置。
编写Button1的Click事件为:
procedure TForm1.Button1Click(Sender: TObject);
begin
If CheckBox1.Checked then
Begin
NMFTP1.Proxy := ProxyserverTxt.Text;
NMFTP1.ProxyPort := StrToInt(ProxyportTxt.Text);
End;
NMFTP1.Host := HostTxt.Text;
NMFTP1.Port := StrToInt(PortTxt.Text);
NMFTP1.Timeout := 5000;
NMFTP1.UserID := UserTxt.Text;
NMFTP1.Password := PassTxt.Text;
try
NMFTP1.Connect;
except
On E:Exception do
writeln(E.message);
end
end;
编写Button2的Click事件为:
procedure TForm1.Button2Click(Sender: TObject);
begin
NMFTP1.Disconnect;
end;
编写Button3的Click事件为:
procedure TForm1.Button3Click(Sender: TObject);
begin
try
NMFTP1.List;
except
end;
end;
另外FTP控件还具有其他功能,如:MakeDirectory(创建目录)、Re
moveDir(删除目录)、Rename(文件更名)、Delete(删除文件)、Uploa
d(上载文件)、Download(下载文件)等,在此不再讲述,大家如需要编
写这些功能,可自己增加。
本程序在Windows98+Delphi5.0下调试通过。
 
谢谢你的回答,这是客户端的代码,我想要服务端的
 
FTP服务器的编写你应该知道FTP协议(有相应的RFC文档下载)的,因为它和客户端是通过请求-应答模式工作的!
你只要建立一个socket来监听自己的特定FTP端口(当然你可以自己设置,但最好用大家都知道的端口:21或者22),如果有相应的请求就回答(至于请求和回答都要符合FTP协议,都是些ASCII码的),然后建立一个新线程和新的工作socket,然后就可以工作,至于它的细节有很多东西,你在网上可以找到这些资料,你也可以使用控件来做,更简单,将所有的底层的东西都包装好了,用就可以了!
 
附带上相应的RFC文档,自己看看吧!
Network Working Group J. Postel
Request for Comments: 959 J. Reynolds
ISI
Obsoletes RFC: 765 (IEN 149) October 1985

FILE TRANSFER PROTOCOL (FTP)


Status of this Memo
This memo is the official specification of the File Transfer
Protocol (FTP). Distribution of this memo is unlimited.
The following new optional commands are included in this edition of
the specification:
CDUP (Change to Parent Directory), SMNT (Structure Mount), STOU
(Store Unique), RMD (Remove Directory), MKD (Make Directory), PWD
(Print Directory), and SYST (System).
Note that this specification is compatible with the previous edition.
1. INTRODUCTION
The objectives of FTP are 1) to promote sharing of files (computer
programs and/or data), 2) to encourage indirect or implicit (via
programs) use of remote computers, 3) to shield a user from
variations in file storage systems among hosts, and 4) to transfer
data reliably and efficiently. FTP, though usable directly by a user
at a terminal, is designed mainly for use by programs.
The attempt in this specification is to satisfy the diverse needs of
users of maxi-hosts, mini-hosts, personal workstations, and TACs,
with a simple, and easily implemented protocol design.
This paper assumes knowledge of the Transmission Control Protocol
(TCP) [2] and the Telnet Protocol [3]. These documents are contained
in the ARPA-Internet protocol handbook [1].
2. OVERVIEW
In this section, the history, the terminology, and the FTP model are
discussed. The terms defined in this section are only those that
have special significance in FTP. Some of the terminology is very
specific to the FTP model; some readers may wish to turn to the
section on the FTP model while reviewing the terminology.
October 1985
File Transfer Protocol
2.1. HISTORY
FTP has had a long evolution over the years. Appendix III is a
chronological compilation of Request for Comments documents
relating to FTP. These include the first proposed file transfer
mechanisms in 1971 that were developed for implementation on hosts
at M.I.T. (RFC 114), plus comments and discussion in RFC 141.
RFC 172 provided a user-level oriented protocol for file transfer
between host computers (including terminal IMPs). A revision of
this as RFC 265, restated FTP for additional review, while RFC 281
suggested further changes. The use of a "Set Data Type"
transaction was proposed in RFC 294 in January 1982.
RFC 354 obsoleted RFCs 264 and 265. The File Transfer Protocol
was now defined as a protocol for file transfer between HOSTs on
the ARPANET, with the primary function of FTP defined as
transfering files efficiently and reliably among hosts and
allowing the convenient use of remote file storage capabilities.
RFC 385 further commented on errors, emphasis points, and
additions to the protocol, while RFC 414 provided a status report
on the working server and user FTPs. RFC 430, issued in 1973,
(among other RFCs too numerous to mention) presented further
comments on FTP. Finally, an "official" FTP document was
published as RFC 454.
By July 1973, considerable changes from the last versions of FTP
were made, but the general structure remained the same. RFC 542
was published as a new "official" specification to reflect these
changes. However, many implementations based on the older
specification were not updated.
In 1974, RFCs 607 and 614 continued comments on FTP. RFC 624
proposed further design changes and minor modifications. In 1975,
RFC 686 entitled, "Leaving Well Enough Alone", discussed the
differences between all of the early and later versions of FTP.
RFC 691 presented a minor revision of RFC 686, regarding the
subject of print files.
Motivated by the transition from the NCP to the TCP as the
underlying protocol, a phoenix was born out of all of the above
efforts in RFC 765 as the specification of FTP for use on TCP.
This current edition of the FTP specification is intended to
correct some minor documentation errors, to improve the
explanation of some protocol features, and to add some new
optionalcommands.
RFC 959 October 1985
File Transfer Protocol
In particular, the following new optional commands are included in
this edition of the specification:
CDUP - Change to Parent Directory
SMNT - Structure Mount
STOU - Store Unique
RMD - Remove Directory
MKD - Make Directory
PWD - Print Directory
SYST - System
This specification is compatible with the previous edition. A
program implemented in conformance to the previous specification
should automatically be in conformance to this specification.
2.2. TERMINOLOGY
ASCII
The ASCII character set is as defined in the ARPA-Internet
Protocol Handbook. In FTP, ASCII characters are defined to be
the lower half of an eight-bit code set (i.e., the most
significant bit is zero).
access controls
Access controls define users' access privileges to the use of a
system, and to the files in that system. Access controls are
necessary to prevent unauthorized or accidental use of files.
It is the prerogative of a server-FTP process to invoke access
controls.
byte size
There are two byte sizes of interest in FTP: the logical byte
size of the file, and the transfer byte size used for the
transmission of the data. The transfer byte size is always 8
bits. The transfer byte size is not necessarily the byte size
in which data is to be stored in a system, nor the logical byte
size for interpretation of the structure of the data.

October 1985
File Transfer Protocol
control connection
The communication path between the USER-PI and SERVER-PI for
the exchange of commands and replies. This connection follows
the Telnet Protocol.
data connection
A full duplex connection over which data is transferred, in a
specified mode and type. The data transferred may be a part of
a file, an entire file or a number of files. The path may be
between a server-DTP and a user-DTP, or between two
server-DTPs.
data port
The passive data transfer process "listens" on the data port
for a connection from the active transfer process in order to
open the data connection.
DTP
The data transfer process establishes and manages the data
connection. The DTP can be passive or active.
End-of-Line
The end-of-line sequence defines the separation of printing
lines. The sequence is Carriage Return, followed by Line Feed.
EOF
The end-of-file condition that defines the end of a file being
transferred.
EOR
The end-of-record condition that defines the end of a record
being transferred.
error recovery
A procedure that allows a user to recover from certain errors
such as failure of either host system or transfer process. In
FTP, error recovery may involve restarting a file transfer at a
given checkpoint.

RFC 959 October 1985
File Transfer Protocol
FTP commands
A set of commands that comprise the control information flowing
from the user-FTP to the server-FTP process.
file
An ordered set of computer data (including programs), of
arbitrary length, uniquely identified by a pathname.
mode
The mode in which data is to be transferred via the data
connection. The mode defines the data format during transfer
including EOR and EOF. The transfer modes defined in FTP are
described in the Section on Transmission Modes.
NVT
The Network Virtual Terminal as defined in the Telnet Protocol.
NVFS
The Network Virtual File System. A concept which defines a
standard network file system with standard commands and
pathname conventions.
page
A file may be structured as a set of independent parts called
pages. FTP supports the transmission of discontinuous files as
independent indexed pages.
pathname
Pathname is defined to be the character string which must be
input to a file system by a user in order to identify a file.
Pathname normally contains device and/or directory names, and
file name specification. FTP does not yet specify a standard
pathname convention. Each user must follow the file naming
conventions of the file systems involved in the transfer.

PI
The protocol interpreter. The user and server sides of the
protocol have distinct roles implemented in a user-PI and a
serverPI.
RFC 959 October 1985
File Transfer Protocol
record
A sequential file may be structured as a number of contiguous
parts called records. Record structures are supported by FTP
but a file need not have record structure.
reply
A reply is an acknowledgment (positive or negative) sent from
server to user via the control connection in response to FTP
commands. The general form of a reply is a completion code
(including error codes) followed by a text string. The codes
are for use by programs and the text is usually intended for
human users.
server-DTP
The data transfer process, in its normal "active" state,
establishes the data connection with the "listening" data port.
It sets up parameters for transfer and storage, and transfers
data on command from its PI. The DTP can be placed in a
"passive" state to listen for, rather than initiate a
connection on the data port.
server-FTP process
A process or set of processes which perform the function of
file transfer in cooperation with a user-FTP process and,
possibly, another server. The functions consist of a protocol
interpreter (PI) and a data transfer process (DTP).
server-PI
The server protocol interpreter "listens" on Port L for a
connection from a user-PI and establishes a control
communication connection. It receives standard FTP commands
from the user-PI, sends replies, and governs the server-DTP.

type

The data representation type used for data transfer and
storage. Type implies certain transformations between the time
of data storage and data transfer. The representation types
defined in FTP are described in the Section on Establishing
Data Connections.

RFC 959 October 1985
File Transfer Protocol
 
接受答案了.
 
后退
顶部