|
||||||||||
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 EventListenerList |
listenerList
List of registered listeners that are willing to get notifications about the activity of this ControlConnection . |
protected BufferedReader |
reader
A Reader object for receiving replies from the remote host. |
protected Socket |
socket
A Socket that represents a connection to the remote host. |
protected 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(String host)
Connects to the given remote host on the default FTP port as defined in FTPConstants.DEFAULT_PORT . |
void |
connect(String host,
int port)
Connects to the specified remote host on the specified port number. |
String |
executeCommand(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. |
InetAddress |
getLocalAddress()
Returns the InetAddress of the local host. |
String |
getLocalHost()
Returns the host name of the local host. |
String |
getLocalIPAddress()
Returns the IP address of the local host. |
int |
getLocalPort()
Retruns the local port number to which this ControlConnection
is connected to. |
InetAddress |
getRemoteAddress()
Returns the remote host's InetAddress . |
String |
getRemoteHost()
Returns the fully qualified domain name of the remote host. |
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. |
String |
getReply()
reads a single FTP response from the remote host. |
SSLSession |
getSSLSession()
Returns the SSLSession associated with this connection. |
boolean |
isSecured()
Tells whether or not this ControlConnection is secured. |
void |
sendCommand(String command)
Sends the given command command , to the remote host over
this ControlConnection . |
protected void |
stderr(String message)
Prints the given string to standard error. |
protected void |
stdout(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 Socket socket
protected BufferedReader reader
protected PrintStream writer
protected EventListenerList listenerList
ControlConnection
.
Constructor Detail |
---|
public ControlConnection(FTPClient client)
ControlConnection
object.
client
- The FTPClient
that created this control
connection.Method Detail |
---|
public void connect(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(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(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 String getReply() throws ConnectionException
ConnectionException
- if a network or IO error occurs while reading the
response.public String executeCommand(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 IOException
ControlConnection
by closing the socket to the
remote host and its associated strems.
IOException
- if a network or IO error occurs while closing this
ControlConnection
.public InetAddress getRemoteAddress()
InetAddress
.
InetAddress
of the remote host.public String getRemoteHost()
public String getRemoteIPAddress()
public int getRemotePort()
ControlConnection
is connected to.
ControlConnection
is connected to.public InetAddress getLocalAddress()
InetAddress
of the local host.
InetAddress
of the local host.public String getLocalHost()
public String getLocalIPAddress()
public int getLocalPort()
ControlConnection
is connected to.
public boolean isSecured()
ControlConnection
is secured.
true
, if this connection is secured.
false
, otherwise.public SSLSession getSSLSession()
protected void fireCommandSent(ControlConnectionEvent evt)
ControlConnectionEvent
object.
evt
- ControlConnectionEvent
.protected void fireReplyReceived(ControlConnectionEvent evt)
evt
- ControlConnectionEvent
.protected void stdout(String message)
message
- The message to print.protected void stderr(String message)
message
- The message to print.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |