KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > connection > ControlConnection


1 package com.coldcore.coloradoftp.connection;
2
3 import com.coldcore.coloradoftp.command.Reply;
4 import com.coldcore.coloradoftp.session.Session;
5
6 /**
7  * Control connection.
8  *
9  * When user connects to a server a control connection is created and assigned to him/her.
10  * One user may have only one control connection which lives until user disconnects.
11  * Control connection accepts user commands, executes them and sends replies.
12  *
13  * Control connection acts as a main point for all users' operations, every user is
14  * identified by a control connection. As a result, control connection has references
15  * to all user-related objects and vice versa.
16  *
17  * Note that a user may also have a single data connection. Which can be created and destroyed
18  * as many times as required while the control connection lives on.
19  * Control connection has a reference to a data connection initiator which is activated
20  * when there is a need to establish a new data connection.
21  *
22  * Control connection may be poisoned at any time. When poisoned, a connection will commit
23  * suicide as soon as all the data is written out to the user and the data connection finishes.
24  * This feature is required to drop connections when server is full: when message is written
25  * out to a user the connection will be dropped right away. Or when a user sends QUIT command,
26  * the control connection will wait until the data connection dies and then it will kill itself.
27  * So poisoned status must be set when user submits QUIT command.
28  *
29  * Some FTP commands put control connection into the INTERRUPT state which is then
30  * cleared when the connection sends a reply. Such reply must refer to a command which
31  * is allowed to clear the state or does not have a reference to a command.
32  * Usually INTERRUPT state is trigerred by data transfer commands and cleared right
33  * after data transfer ends.
34  *
35  *
36  * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
37  */

38 public interface ControlConnection extends Connection {
39
40   /** Reply to user
41    * @param reply Reply
42    */

43   public void reply(Reply reply);
44
45
46   /** Get user session
47    * @return Session
48    */

49   public Session getSession();
50
51
52   /** Get data connection of this control connection
53    * @return Data connection or NULL if does not have one
54    */

55   public DataConnection getDataConnection();
56
57
58   /** Set data connection of this control connection
59    * @param dataConnection Data connection
60    */

61   public void setDataConnection(DataConnection dataConnection);
62
63
64   /** Get data connection initiator
65    * @return Initiator
66    */

67   public DataConnectionInitiator getDataConnectionInitiator();
68
69
70   /** Get text length that awaits in the outgoing to user buffer
71    * @return Test length
72    */

73   public int getOutgoingBufferSize();
74
75
76   /** Get text length that awaits in the incoming from user buffer
77    * @return Test length
78    */

79   public int getIncomingBufferSize();
80 }
81
Popular Tags