| java.lang.Object com.enterprisedt.net.ftp.FTPControlSocket
FTPControlSocket | public class FTPControlSocket (Code) | | Supports client-side FTP operations
author: Bruce Blackshaw version: $Revision: 1.40 $ |
Method Summary | |
public void | close() | FTPDataSocket | createDataSocket(FTPConnectMode connectMode) Request a data socket be created on the
server, connect to it and return our
connected socket. | FTPDataSocket | createDataSocketActive() Request a data socket be created on the Client
client on any free port, do not connect it to yet. | protected FTPDataSocket | createDataSocketPASV() Request a data socket be created on the
server, connect to it and return our
connected socket. | boolean | getListenOnAllInterfaces() | int[] | getPASVParts(String reply) | String | getRemoteHostName() | protected void | initStreams() Initialize the reader/writer streams for this connection. | void | log(String msg, boolean command) | public void | logout() Quit this FTP session and clean up. | protected FTPDataSocket | newActiveDataSocket(int port) Constructs a new FTPDataSocket object (server mode) which will
listen on the given port number.
Parameters: port - Remote port to listen on. | protected FTPDataSocket | newPassiveDataSocket(String remoteHost, int port) Constructs a new FTPDataSocket object (client mode) and connect
to the given remote host and port number.
Parameters: remoteHost - Remote host to connect to. Parameters: port - Remote port to connect to. | FTPReply | readReply() Read the FTP server's reply to a previously
issued command. | public FTPReply | sendCommand(String command) | void | sendPORTCommand(short port) | void | setActivePortIPAddress(String forcedActiveIP) We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. | public void | setActivePortRange(int lowest, int highest) | protected void | setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution) | protected void | setDataPort(InetAddress host, short portNo) Sets the data port on the server, that is, sends a PORT
command. | void | setListenOnAllInterfaces(boolean listenOnAll) Listen on all interfaces for active mode transfers (the default). | void | setMessageListener(FTPMessageListener listener) | void | setStrictReturnCodes(boolean strict) Set strict checking of FTP return codes. | void | setTimeout(int millis) Set the TCP timeout on the underlying control socket. | protected byte[] | toByteArray(short value) | FTPReply | validateReply(String reply, String expectedReplyCode) Validate the response the host has supplied against the
expected reply. | public FTPReply | validateReply(String reply, String[] expectedReplyCodes) Validate the response the host has supplied against the
expected reply. | public FTPReply | validateReply(FTPReply reply, String[] expectedReplyCodes) Validate the response the host has supplied against the
expected reply. | public FTPReply | validateReply(FTPReply reply, String expectedReplyCode) Validate the response the host has supplied against the
expected reply. | void | writeCommand(String command) Send a command to the FTP server. |
CONTROL_PORT | final public static int CONTROL_PORT(Code) | | The default and standard control port number for FTP
|
EOL | final static String EOL(Code) | | Standard FTP end of line sequence
|
autoPassiveIPSubstitution | protected boolean autoPassiveIPSubstitution(Code) | | If true, uses the original host IP if an internal IP address
is returned by the server in PASV mode
|
controlSock | protected Socket controlSock(Code) | | The underlying socket.
|
cvsId | final public static String cvsId(Code) | | Revision control id
|
forcedActiveIP | protected String forcedActiveIP(Code) | | IP address we force PORT to send - useful with certain
NAT configurations
|
listenOnAllInterfaces | protected boolean listenOnAllInterfaces(Code) | | Listen to all interfaces in active mode
|
reader | protected BufferedReader reader(Code) | | The reader that reads control data from the
control socket
|
writer | protected Writer writer(Code) | | The write that writes to the control socket
|
FTPControlSocket | protected FTPControlSocket(InetAddress remoteAddr, int controlPort, int timeout, String encoding, FTPMessageListener messageListener) throws IOException, FTPException(Code) | | Constructor. Performs TCP connection and
sets up reader/writer. Allows different control
port to be used
Parameters: remoteAddr - Remote inet address Parameters: controlPort - port for control stream Parameters: timeout - the length of the timeout, in milliseconds Parameters: encoding - character encoding used for data Parameters: messageListener - listens for messages |
FTPControlSocket | protected FTPControlSocket(InetAddress remoteAddr, Socket controlSock, int timeout, String encoding, FTPMessageListener messageListener) throws IOException, FTPException(Code) | | Constructs a new FTPControlSocket using the given
Socket object.
Parameters: remoteAddr - the remote address Parameters: controlSock - Socket to be used. Parameters: timeout - Timeout to be used. Parameters: encoding - character encoding used for data Parameters: messageListener - listens for messages throws: IOException - Thrown if no connection response could be read from the server. throws: FTPException - Thrown if the incorrect connection response was sent by the server. |
createDataSocket | FTPDataSocket createDataSocket(FTPConnectMode connectMode) throws IOException, FTPException(Code) | | Request a data socket be created on the
server, connect to it and return our
connected socket.
Parameters: active - if true, create in active mode, elsein passive mode connected data socket |
createDataSocketActive | FTPDataSocket createDataSocketActive() throws IOException, FTPException(Code) | | Request a data socket be created on the Client
client on any free port, do not connect it to yet.
not connected data socket |
createDataSocketPASV | protected FTPDataSocket createDataSocketPASV() throws IOException, FTPException(Code) | | Request a data socket be created on the
server, connect to it and return our
connected socket.
connected data socket |
getListenOnAllInterfaces | boolean getListenOnAllInterfaces()(Code) | | Are we listening on all interfaces in active mode, which is the default?
true if listening on all interfaces, false if listening just on the control interface |
getRemoteHostName | String getRemoteHostName()(Code) | | Get the name of the remote host
remote host name |
initStreams | protected void initStreams() throws IOException(Code) | | Initialize the reader/writer streams for this connection.
|
log | void log(String msg, boolean command)(Code) | | Log a message, checking for passwords
Parameters: msg - message to log Parameters: reply - true if a response, false otherwise |
logout | public void logout() throws IOException(Code) | | Quit this FTP session and clean up.
|
newActiveDataSocket | protected FTPDataSocket newActiveDataSocket(int port) throws IOException(Code) | | Constructs a new FTPDataSocket object (server mode) which will
listen on the given port number.
Parameters: port - Remote port to listen on. A new FTPDataSocket object (server mode) which isconfigured to listen on the given port. throws: IOException - Thrown if an error occurred when creating the socket. |
newPassiveDataSocket | protected FTPDataSocket newPassiveDataSocket(String remoteHost, int port) throws IOException(Code) | | Constructs a new FTPDataSocket object (client mode) and connect
to the given remote host and port number.
Parameters: remoteHost - Remote host to connect to. Parameters: port - Remote port to connect to. A new FTPDataSocket object (client mode) which isconnected to the given server. throws: IOException - Thrown if no TCP/IP connection could be made. |
readReply | FTPReply readReply() throws IOException(Code) | | Read the FTP server's reply to a previously
issued command. RFC 959 states that a reply
consists of the 3 digit code followed by text.
The 3 digit code is followed by a hyphen if it
is a multiline response, and the last line starts
with the same 3 digit code.
structured reply object |
sendCommand | public FTPReply sendCommand(String command) throws IOException(Code) | | Send a command to the FTP server and
return the server's reply as a structured
reply object
Parameters: command - command to send reply to the supplied command |
setActivePortIPAddress | void setActivePortIPAddress(String forcedActiveIP)(Code) | | We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. Must be connected to the remote host to call this method.
Parameters: forcedActiveIP - IP address to force |
setActivePortRange | public void setActivePortRange(int lowest, int highest)(Code) | | Set the port number range for active mode
Parameters: lowest - lowest port number in range Parameters: highest - highest port number in range |
setAutoPassiveIPSubstitution | protected void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)(Code) | | Set automatic substitution of the remote host IP on if
in passive mode
Parameters: autoPassiveIPSubstitution - true if set to on, false otherwise |
setDataPort | protected void setDataPort(InetAddress host, short portNo) throws IOException, FTPException(Code) | | Sets the data port on the server, that is, sends a PORT
command.
Parameters: host - the local host the server will connect to Parameters: portNo - the port number to connect to |
setListenOnAllInterfaces | void setListenOnAllInterfaces(boolean listenOnAll)(Code) | | Listen on all interfaces for active mode transfers (the default).
Parameters: listenOnAll - true if listen on all interfaces, false to listen on the control interface |
setMessageListener | void setMessageListener(FTPMessageListener listener)(Code) | | Set a listener that handles all FTP messages
Parameters: listener - message listener |
setStrictReturnCodes | void setStrictReturnCodes(boolean strict)(Code) | | Set strict checking of FTP return codes. If strict
checking is on (the default) code must exactly match the expected
code. If strict checking is off, only the first digit must match.
Parameters: strict - true for strict checking, false for loose checking |
setTimeout | void setTimeout(int millis) throws IOException(Code) | | Set the TCP timeout on the underlying control socket.
If a timeout is set, then any operation which
takes longer than the timeout value will be
killed with a java.io.InterruptedException.
Parameters: millis - The length of the timeout, in milliseconds |
toByteArray | protected byte[] toByteArray(short value)(Code) | | Convert a short into a byte array
Parameters: value - value to convert a byte array |
validateReply | FTPReply validateReply(String reply, String expectedReplyCode) throws FTPException(Code) | | Validate the response the host has supplied against the
expected reply. If we get an unexpected reply we throw an
exception, setting the message to that returned by the
FTP server
Parameters: reply - the entire reply string we received Parameters: expectedReplyCode - the reply we expected to receive |
validateReply | public FTPReply validateReply(String reply, String[] expectedReplyCodes) throws IOException, FTPException(Code) | | Validate the response the host has supplied against the
expected reply. If we get an unexpected reply we throw an
exception, setting the message to that returned by the
FTP server
Parameters: reply - the entire reply string we received Parameters: expectedReplyCodes - array of expected replies an object encapsulating the server's reply |
validateReply | public FTPReply validateReply(FTPReply reply, String[] expectedReplyCodes) throws FTPException(Code) | | Validate the response the host has supplied against the
expected reply. If we get an unexpected reply we throw an
exception, setting the message to that returned by the
FTP server
Parameters: reply - reply object Parameters: expectedReplyCodes - array of expected replies reply object |
validateReply | public FTPReply validateReply(FTPReply reply, String expectedReplyCode) throws FTPException(Code) | | Validate the response the host has supplied against the
expected reply. If we get an unexpected reply we throw an
exception, setting the message to that returned by the
FTP server
Parameters: reply - reply object Parameters: expectedReplyCode - expected reply reply object |
writeCommand | void writeCommand(String command) throws IOException(Code) | | Send a command to the FTP server. Don't
read the reply
Parameters: command - command to send |
|
|