|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.myjavaworld.ftp.ControlConnection
public class ControlConnection
This class represents a Control Connection as specified in the FTP protocol specification. For more details refer to RFC 959.
| Field Summary | |
|---|---|
protected FTPClient |
client
FTPClient object that created this
ControlConnection. |
protected javax.swing.event.EventListenerList |
listenerList
List of registered listeners that are willing to get notifications about the activity of this ControlConnection. |
protected java.io.BufferedReader |
reader
A Reader object for receiving replies from the remote host. |
protected java.net.Socket |
socket
A Socket that represents a connection to the remote host. |
protected java.io.PrintStream |
writer
A Writer object that sends commands to the remote host. |
| Fields inherited from interface com.myjavaworld.ftp.FTPConstants |
|---|
DEFAULT_BUFFER_SIZE, DEFAULT_IMPLICIT_SSL_PORT, DEFAULT_MODE, DEFAULT_PORT, DEFAULT_STRUCTURE, DEFAULT_TIMEOUT, DEFAULT_TYPE, EOL, MODE_BLOCK, MODE_COMPRESSED, MODE_STREAM, STRUCTURE_FILE, STRUCTURE_PAGE, STRUCTURE_RECORD, TYPE_ASCII, TYPE_BINARY, TYPE_EBCDIC, TYPE_IMAGE, TYPE_LOCAL, USE_EXPLICIT_SSL, USE_IMPLICIT_SSL, USE_NO_SSL, USE_SSL_IF_AVAILABLE |
| Constructor Summary | |
|---|---|
ControlConnection(FTPClient client)
Constructs a ControlConnection object. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this ControlConnection by closing the socket to the
remote host and its associated strems. |
void |
connect(java.lang.String host)
Connects to the given remote host on the default FTP port as defined in FTPConstants.DEFAULT_PORT. |
void |
connect(java.lang.String host,
int port)
Connects to the specified remote host on the specified port number. |
java.lang.String |
executeCommand(java.lang.String command)
Executes the given command command. |
protected void |
fireCommandSent(ControlConnectionEvent evt)
Used to notify registered listeners that a command was sent to the remote host. |
protected void |
fireReplyReceived(ControlConnectionEvent evt)
Used to notify the registered listeners that a reply was received from the remote host. |
java.net.InetAddress |
getLocalAddress()
Returns the InetAddress of the local host. |
java.lang.String |
getLocalHost()
Returns the host name of the local host. |
java.lang.String |
getLocalIPAddress()
Returns the IP address of the local host. |
int |
getLocalPort()
Retruns the local port number to which this ControlConnection
is connected to. |
java.net.InetAddress |
getRemoteAddress()
Returns the remote host's InetAddress. |
java.lang.String |
getRemoteHost()
Returns the fully qualified domain name of the remote host. |
java.lang.String |
getRemoteIPAddress()
Returns the IP address of the remote host in xxx.xxx.xxx.xxx format. |
int |
getRemotePort()
Returns the remote port number to which this ControlConnection is connected to. |
java.lang.String |
getReply()
reads a single FTP response from the remote host. |
javax.net.ssl.SSLSession |
getSSLSession()
Returns the SSLSession associated with this connection. |
boolean |
isSecured()
Tells whether or not this ControlConnection is secured. |
void |
sendCommand(java.lang.String command)
Sends the given command command, to the remote host over
this ControlConnection. |
protected void |
stderr(java.lang.String message)
Prints the given string to standard error. |
protected void |
stdout(java.lang.String message)
Prints a given string to the standard output. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected FTPClient client
FTPClient object that created this
ControlConnection.
protected java.net.Socket socket
protected java.io.BufferedReader reader
protected java.io.PrintStream writer
protected javax.swing.event.EventListenerList listenerList
ControlConnection.
| Constructor Detail |
|---|
public ControlConnection(FTPClient client)
ControlConnection object.
client - The FTPClient that created this control
connection.| Method Detail |
|---|
public void connect(java.lang.String host)
throws ConnectionException,
FTPException
FTPConstants.DEFAULT_PORT.
host - Host name or IP address of the remote host.
ConnectionException - if unable to connect to the specified host.
FTPException
public void connect(java.lang.String host,
int port)
throws ConnectionException,
FTPException
host - Host name or IP address of the remote host.port - Port number to connect to.
ConnectionException - If unable to connect to the specified host.
FTPException
public void sendCommand(java.lang.String command)
throws ConnectionException
command, to the remote host over
this ControlConnection. All commands will be appended
with telnet end of line (\r\n) characters before sending to the remote
host.
command - Command to send to the remote host.
ConnectionException - if a network or IO error occurs while sending the command.
public java.lang.String getReply()
throws ConnectionException
ConnectionException - if a network or IO error occurs while reading the
response.
public java.lang.String executeCommand(java.lang.String command)
throws ConnectionException
command. This method is
similar to calling the sendCommand and
getReply methods sequentially.
command - The command to be sent to the remote host.
ConnectionException - if a network or IO error occurs.
public void close()
throws java.io.IOException
ControlConnection by closing the socket to the
remote host and its associated strems.
java.io.IOException - if a network or IO error occurs while closing this
ControlConnection.public java.net.InetAddress getRemoteAddress()
InetAddress.
InetAddress of the remote host.public java.lang.String getRemoteHost()
public java.lang.String getRemoteIPAddress()
public int getRemotePort()
ControlConnection is connected to.
ControlConnection
is connected to.public java.net.InetAddress getLocalAddress()
InetAddress of the local host.
InetAddress of the local host.public java.lang.String getLocalHost()
public java.lang.String getLocalIPAddress()
public int getLocalPort()
ControlConnection
is connected to.
public boolean isSecured()
ControlConnection is secured.
true, if this connection is secured.
false, otherwise.public javax.net.ssl.SSLSession getSSLSession()
protected void fireCommandSent(ControlConnectionEvent evt)
ControlConnectionEvent
object.
evt - ControlConnectionEvent.protected void fireReplyReceived(ControlConnectionEvent evt)
evt - ControlConnectionEvent.protected void stdout(java.lang.String message)
message - The message to print.protected void stderr(java.lang.String message)
message - The message to print.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||