Posts Tagged ‘FTP Client over SOCKS Proxy’

FTP Client Using Apache Common net library using Socks Proxy Server

August 2, 2012 1 comment

As we have the FTP Server code in previous post, here is a FTP Client using Apache Commons library.  Below is a basic code which we can use to connect to our FTP server which we created over a SOCKS Proxy Server. (Assuming you have a SOCKS proxy server running already – if not then code can be used just as a FTP Client to connect directly to FTP Server).

Below Image shows, libraries required and parameter passed from the build.xml (this can be done over the command line as well)


Below Image shows changes required to Route all Packets to go through Proxy Server



Libraries Required.

<path id="FtpClientDemo.classpath">
        <pathelement location="bin"/>
        <pathelement location="lib/commons-net-3.1-ftp.jar"/>
        <pathelement location="lib/commons-net-3.1.jar"/>

Sample Arg in Build.xml File

<target name="FtpClientDemo">
    <java classname="com.ftp.client.FtpClient" failonerror="true" fork="yes">
        <jvmarg line=""/>
        <!-- Proxy Argument Below -->
        <!-- <arg line="-PrH -p true -b -s sipl sipl LookAppCode.rar f:\LookAppCode.rar"/> -->
        <!-- Normal Connection to FTPServer without Proxy -->
        <arg line="-l ahmed ahmed"/>
        <classpath refid="FtpClientDemo.classpath"/>

Read more…