SIGN UP MEMBER LOGIN:    
ARTICLE

FTP Server in C#

Posted by Pramod Singh Articles | Internet & Web March 26, 2001
The application is a simple implementation of FTP Protocol RFC 959.
Reader Level:
Download Files:
 

Introduction

The application is a simple implementation of FTP Protocol RFC 959.

Technology Used

System.Net.Socket,Multithreading.

FTP  : 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 FTP MODEL

With the above definitions in mind, the following model (shown in  Figure 1) may be diagrammed for an FTP service.

In the model described in Figure 1, the user-protocol interpreter initiates the control connection. The control connection follows the Telnet protocol. At the initiation of the user, standard FTP commands are generated by the user-PI and transmitted to the server process via the control connection. (The user may establish a direct control connection to the server-FTP, from a TAC terminal for example, and generate standard FTP commands independently, bypassing the user-FTP process.) Standard replies are sent from the server-PI to the user-PI over the control connection in response to the commands.

The FTP commands specify the parameters for the data connection (data port, transfer mode, representation type, and structure) and the nature of file system operation (store, retrieve, append, delete, etc.). The user-DTP or its designate should "listen" on the specified data port, and the server initiate the data connection and data transfer in accordance with the specified parameters. It should be noted that the data port need not be in the same host that initiates the FTP commands via the control connection, but the user or the user-FTP process must ensure a "listen" on the specified data port. It ought to also be noted that the data connection may be used for simultaneous sending and receiving. In another situation a user might wish to transfer files between two hosts, neither of which is a local host. The user sets up control connections to the two servers and then arranges for a data connection between them. In this manner, control information is passed to the user-PI but data is transferred between the server data transfer processes. Following is a model of this server-server interaction.



The protocol requires that the control connections be open while data transfer is in progress. It is the responsibility of the user to request the closing of the control connections when finished using the FTP service, while it is the server who takes the action. The server may abort data transfer if the control connections are closed without command.

About the sample

Server is a Win Form application which acts as a Console window for the application. As this application is a multithreaded application it can handle lot many clients. Their is session window from where you can end any of the current session of the client . At present in this application you will be just see "System.Thread " and you can select a item and say disconnect which will disconnect the Client from the Server. Present application uses C: as the directory and I have not provided any setup screen, this means there is no user and no password too, any one can log to this server with any user name and any password. You can very easily make this changes in the code and can use this.

Good luck and Enjoy C#

Login to add your contents and source code to this article
share this article :
post comment
 

hi I run program but wasn't.I don't understand why? So, I want run 1 FTP Server Program , What do I need to do ??? Thanhs !

Posted by Nguyen Hoang Lan Mar 07, 2009

How files and folders will directly transfer between two remote servers? Can you please suggest how can i achieve this in .Net web appication?

Posted by Nitin Gangwar Dec 18, 2007

How to Create a Windows Service to FTP the file

Posted by Dilip Raju Aug 06, 2007
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor