Example 6: SOCKS 5 Client

This example illustrates the use  ProFTPClient's SOCKS5 functionality.

The example performs the following operations:

  1. Sets up SOCKS5 context.
  2. Connects to the FTP server through the SOCKS proxy.
  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 SOCKS5 proxy and FTP server.
    You may like to use EDT's free FTP/FTPS server, edtFTPD , for this purpose.
  2. Open a console window.
  3. Change to the examples/Ex6_Socks5Client directory.
  4. Run the example by:
    run host-name username password filename proxy-server [proxy-user]
    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). 
    proxy-server is the address/name of the SOCKS5 proxy.
    proxy-user is the user-name of the user account on the SOCKS5 proxy.
    proxy-password is the password of the user account on the SOCKS5 proxy.

    The proxy-user and the proxy-password are required if the SOCKS5 proxy has been configured to use user-name/password authentication.
  5. Verify that the output looks something like this:
    INFO [Socks5Client] 26 Jan 2005 15:00:43.165 : Creating FTP-via-SOCKS5 client
    INFO [Socks5Client] 26 Jan 2005 15:00:43.175 : Setting FTP server address
    INFO [Socks5Client] 26 Jan 2005 15:00:43.185 : Setting SOCKS5 context
    INFO [Socks5Client] 26 Jan 2005 15:00:43.195 : Connecting to server LOCALHOST
    INFO [Socks5Client] 26 Jan 2005 15:00:43.255 : Logging in with username=test and password=test
    INFO [Socks5Client] 26 Jan 2005 15:00:43.265 : Setting up passive, ASCII transfers
    INFO [Socks5Client] 26 Jan 2005 15:00:43.265 : Directory before put:
    INFO [Socks5Client] 26 Jan 2005 15:00:43.306 :   no files
    INFO [Socks5Client] 26 Jan 2005 15:00:43.306 : Putting Socks5Client.exe to server
    INFO [Socks5Client] 26 Jan 2005 15:00:43.356 : Directory after put:
    INFO [Socks5Client] 26 Jan 2005 15:00:43.386 : -rw-rw-rw-   1 user     group       16318 Jan 26 15:00 Socks5Client.exe
    INFO [Socks5Client] 26 Jan 2005 15:00:43.386 : Getting Socks5Client.exe from server and saving as Socks5Client.exe.copy
    INFO [Socks5Client] 26 Jan 2005 15:00:43.446 : Deleting Socks5Client.exe
    INFO [Socks5Client] 26 Jan 2005 15:00:43.456 : Directory after delete:
    INFO [Socks5Client] 26 Jan 2005 15:00:43.486 :   no files
    INFO [Socks5Client] 26 Jan 2005 15:00:43.486 : Quitting client    
    
    There should now also be a file called YourFilename.copy in the local directory.