Example 5: SOCKS 4 Client

This example illustrates the use  ProFTPClient's SOCKS4 functionality.

The example performs the following operations:

  1. Sets up SOCKS4 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 SOCKS4 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/Ex5_Socks4Client 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 SOCKS4 proxy.
    proxy-user is the user-name of the user account on the SOCKS4 proxy.
  5. Verify that the output looks something like this:
    INFO [Socks4Client] 26 Jan 2005 14:48:43.020 : Creating FTP-via-SOCKS4 client 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.030 : Setting FTP server address
    INFO [Socks4Client] 26 Jan 2005 14:48:43.030 : Setting SOCKS4 context     
    INFO [Socks4Client] 26 Jan 2005 14:48:43.040 : Connecting to server LOCALHOST 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.100 : Logging in with username=test and password= test 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.100 : Setting up passive, ASCII transfers 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.110 : Directory before put: 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.150 :   no files 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.150 : Putting Socks4Client.exe to server 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.190 : Directory after put: 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.230 : -rw-rw-rw- 1  user group 16334 Jan 26 14:48 Socks4Client.exe 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.230 : Getting Socks4Client.exe from serverand saving as Socks4Client.exe.copy 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.310 : Deleting Socks4Client.exe 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.320 : Directory after delete: 
    INFO [Socks4Client] 26 Jan 2005 14:48:43.350 :   no files
    INFO [Socks4Client] 26 Jan 2005 14:48:43.350 : Quitting client
    There should now also be a file called YourFilename.copy in the local directory.