Overview
FXP is a method of transferring data from one server to another server without routing this data through the client. FTP involves a single client and a single server, FXP on the other hand involves the client having two connections to two different servers (let's call them server A and server B). The client can transfer between these two servers in either direction (from A to B OR from B to A). The obvious advantage of using FXP is that the data transfer is more efficient specially for clients with slow connections.
One potential disadvantage of using FXP is that the server is vulnerable to "FTP Bounce" attack. More information regarding this can be found here.
Example
Download FXPExample.java
01 import com.jscape.inet.ftp.*;
02
03 public class Main
04 {
05 public static void main(String[] args)
06 {
07 String srcHostname = null;
08 String srcUsername = null;
09 String srcPassword = null;
10 String destHostname = null;
11 String destUsername = null;
12 String destPassword = null;
13
14 try
15 {
16 // create source and destination servers
17 Ftp source = new Ftp(srcHostname,srcUsername,srcPassword);
18 Ftp destination = new Ftp(destHostname,destUsername,destPassword);
19 destination.connect();
20 source.connect();
21
22 // set source directory of Ftp instance
23 source.setDir("/src");
24
25 // set destination directory of Ftp instance
26 destination.setDir("/dest");
27
28 Fxp fxp = new Fxp();
29 // transfer file "filename.txt" from source to destination
30 fxp.transfer(source,destination,"filename.txt");
31 // transfer directory "images" from source to destination
32 fxp.transferDir(source,destination,"images");
33 // transfer files ending with .gif extension from source to destination
34 fxp.mtransfer(source,destination,".*\\.gif");
35 }
36 catch (Exception e)
37 {
38 e.printStackTrace();
39 }
40 }
41 }
Lines 17-18 : Create source and destination Ftp instances. Line 23 : Set the source directory to transfer from. Line 26 : Set the destination directory to transfer to. Line 28 : Create the Fxp instance. Line 30-31 : Transfer files and directories respectively.
|
Comments