Delphi-Kylix
  Home arrow Delphi-Kylix arrow The Implementation of an FTP Server
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

The Implementation of an FTP Server
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2007-02-05

    Table of Contents:
  • The Implementation of an FTP Server
  • The Code
  • Deleting Files
  • Listing Files
  • Making and Removing Directories
  • Authenticating Users

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The Implementation of an FTP Server


    (Page 1 of 6 )

    In the previous article, we discussed RFC 959, which defines how an FTP server should work. We also walked through some of the commands that are used in this protocol. In this article, we will be creating an example FTP server in Delphi.

    Required Tools

    Delphi 6 or higher and Indy 10.1.5, the latest snapshot. I've only tested this application on Windows XP, so, although  I do not think you will encounter any problems on most other platforms, please let me know if you do. I will try to make the application as platform agnostic as possible.

    The application

    To create our FTP server, we are going to use the idftpserver component available in Delphi. This component implements all the commands needed to create a viable server application. As always, I am going to implement as many commands as possible in this application, but by no means all of them. To implement an FTP server application that meets the minimum requirements you need to:

    • Be able to show all files in a given directory.
    • Change and remove a directory.
    • Upload and download files.
    • Delete and view file details.
    • Authenticate a user.

    There are many more commands, but you can just about get on with implementing the minimum. To see how many commands you can implement with Indy,  drop an idftpserver component on a form and look at the object inspectors events tab. Indy has done most of the interpreting of the FTP protocol, and thus makes it easy to implement the commands. 

    Start Delphi and create a new application. On the form add the following components:

    •  One Memo
    • Three Edits
    • Two Buttons
    • Four Labels

    In edit1's text property add "myusername" and on edit2's text property add "mypassword."  Then from the Indy servers tab drop the idFTPServer component, and from the Indy intercepts tab drop a TidServerInterceptlogfile component; rename it to logfile1.  Now we need to connect this intercept to the idftpserver component. So click on the idftpserver component, go to its intercept property on the object inspector and click on the drop down arrow. It should contain the word "logfile1." Select it and we're done.

    On button1 add the caption "Connect" and on button2 add the caption "Exit." Double click on button1 and add the following code:

    procedure TForm1.Button1Click(Sender: TObject); begin idftpserver1.DefaultPort:=strtoint(edit3.text); idftpserver1.Active:=true; showmessage('Connected'); end;

    Then do the same for button2 but add the following code:

    procedure TForm1.Button2Click(Sender: TObject); begin idftpserver1.Active:=false; close; end;

    Button1 does a couple of things. It activates the ftpserver application and also sets the default port, which is number 21. The port number is very important because it is where the client application is going to try to connect to the server.  Button2 just closes down the application. Your form should now look something like this:

    More Delphi-Kylix Articles
    More By Leidago


       · FTP server implementation is very easy when it is done with Delphi and the Indy...
     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT