Example 4: Implicit Client

This example illustrates the use of ProFTPClient in implicit FTPS mode with neither server nor client validation. This is not recommended usage since there is no way for either party to ensure the other party is who it claims to be, but it serves well to illustrate basic usage.

The example performs the following operations:

  1. Switches off server validation.
  2. Connects to the server in implicit FTPS mode.
  3. Logs in.
  4. Lists directory contents.
  5. Puts a file to the server.
  6. Lists directory contents.
  7. Gets the same file back from the server.
  8. Lists directory contents.
  9. Disconnects.

You can view the source-code here.

INSTRUCTIONS:

  1. Make sure you have a working FTP server with implicit FTPS enabled.
    (Note that edtFTPD does not support implicit FTPS)
  2. Open a console window.
  3. Change to the examples/Ex4_ImplicitClient directory.
  4. Run the example by:
    run host-name username password filename
    
    where
    host-name is the address/name of the FTP server.
    username is the username of the user account on the FTP server.
    password is the password of the user account on the FTP server.
    filename is the name of the ASCII file in the current dir you wish to transfer (less than 10K in size for the trial).
  5. Verify that the output looks something like this:
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:22.746 : Creating FTPS (implicit) client
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:22.986 : Turning off server validation
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:22.986 : Connecting to server localhost
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.517 : Logging in with username=test and password=test
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.527 : Setting up passive, ASCII transfers
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.537 : Directory before put:
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.617 :   no files
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.617 : Putting YourFilename to server
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.687 : Directory after put:
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.747 :   -rw-rw-rw-   1 user     group        3409 May 11 15:46 ImplicitClient.exe
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.747 : Getting ImplicitClient.exe from server and saving as ImplicitClient.exe.copy
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.797 : Deleting ImplicitClient.exe
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.797 : Directory after delete:
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.837 :   no files
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.837 : Quitting client
    INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 25 Nov 2004 15:46:23.837 : Test complete
    
    There should now also be a file called YourFilename.copy in the local directory.