1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package gnu.inet.ftp;
22
23 import java.io.IOException;
24 import java.net.Socket;
25 import java.net.UnknownHostException;
26
27 /***
28 * This class encapsulates the parameters of a passive data connection.
29 */
30 public class PassiveConnection extends Object {
31
32
33 private PassiveParameters parameters;
34 private Socket sock;
35
36
37
38
39
40 /***
41 * create a new instance of PassiveParameters
42 *
43 * @param parameters
44 * passive connection parameters
45 */
46 public PassiveConnection(PassiveParameters parameters)
47 throws UnknownHostException, IOException {
48 this.parameters = parameters;
49 this.sock = new Socket(parameters.getInetAddress(), parameters
50 .getPort());
51 }
52
53 /***
54 * get the passive parameters
55 *
56 * @return passive parameter data
57 */
58 public PassiveParameters getPassiveParameters() {
59 return parameters;
60 }
61
62 /***
63 * get the socket for this passive connection
64 *
65 * @return the socket for this passive connection
66 */
67 public Socket getSocket() {
68 return this.sock;
69 }
70
71 /***
72 * compare another PassiveConnection instance to this one.
73 *
74 * @param other
75 * the other instance to compare this one with
76 * @return true if the other instance equals this one, false if they are not
77 * equal
78 */
79 public boolean equals(PassiveConnection other) {
80 if (this.parameters.equals(other.parameters)) {
81 return true;
82 }
83 return false;
84 }
85
86 }
87
88