|
edtFTPj | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.enterprisedt.net.ftp.FTPControlSocket
public class FTPControlSocket
Supports client-side FTP operations
Field Summary | |
---|---|
protected boolean |
autoPassiveIPSubstitution
If true, uses the original host IP if an internal IP address is returned by the server in PASV mode |
static int |
CONTROL_PORT
The default and standard control port number for FTP |
protected Socket |
controlSock
The underlying socket. |
static String |
cvsId
Revision control id |
protected String |
forcedActiveIP
IP address we force PORT to send - useful with certain NAT configurations |
protected BufferedReader |
reader
The reader that reads control data from the control socket |
protected InetAddress |
remoteAddr
The remote address to connect to |
protected Writer |
writer
The write that writes to the control socket |
Constructor Summary | |
---|---|
protected |
FTPControlSocket(InetAddress remoteAddr,
int controlPort,
int timeout,
String encoding,
FTPMessageListener messageListener)
Constructor. |
protected |
FTPControlSocket(InetAddress remoteAddr,
Socket controlSock,
int timeout,
String encoding,
FTPMessageListener messageListener)
Constructs a new FTPControlSocket using the given
Socket object. |
Method Summary | |
---|---|
void |
close()
Close the socket |
protected FTPDataSocket |
createDataSocketPASV()
Request a data socket be created on the server, connect to it and return our connected socket. |
protected void |
initStreams()
Initialize the reader/writer streams for this connection. |
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. |
protected FTPDataSocket |
newPassiveDataSocket(String remoteHost,
int port)
Constructs a new FTPDataSocket object (client mode) and connect
to the given remote host and port number. |
FTPReply |
sendCommand(String command)
Send a command to the FTP server and return the server's reply as a structured reply object |
void |
setActivePortRange(int lowest,
int highest)
Set the port number range for active mode |
protected void |
setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
Set automatic substitution of the remote host IP on if in passive mode |
protected void |
setDataPort(InetAddress host,
short portNo)
Sets the data port on the server, that is, sends a PORT command. |
protected byte[] |
toByteArray(short value)
Convert a short into a byte array |
FTPReply |
validateReply(FTPReply reply,
String expectedReplyCode)
Validate the response the host has supplied against the expected reply. |
FTPReply |
validateReply(FTPReply reply,
String[] expectedReplyCodes)
Validate the response the host has supplied against the expected reply. |
FTPReply |
validateReply(String reply,
String[] expectedReplyCodes)
Validate the response the host has supplied against the expected reply. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String cvsId
public static final int CONTROL_PORT
protected Socket controlSock
protected Writer writer
protected BufferedReader reader
protected String forcedActiveIP
protected InetAddress remoteAddr
protected boolean autoPassiveIPSubstitution
Constructor Detail |
---|
protected FTPControlSocket(InetAddress remoteAddr, int controlPort, int timeout, String encoding, FTPMessageListener messageListener) throws IOException, FTPException
remoteAddr
- Remote inet addresscontrolPort
- port for control streamtimeout
- the length of the timeout, in millisecondsencoding
- character encoding used for datamessageListener
- listens for messages
IOException
FTPException
protected FTPControlSocket(InetAddress remoteAddr, Socket controlSock, int timeout, String encoding, FTPMessageListener messageListener) throws IOException, FTPException
FTPControlSocket
using the given
Socket
object.
remoteAddr
- the remote addresscontrolSock
- Socket to be used.timeout
- Timeout to be used.encoding
- character encoding used for datamessageListener
- listens for messages
IOException
- Thrown if no connection response could be read from the server.
FTPException
- Thrown if the incorrect connection response was sent by the server.Method Detail |
---|
protected void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
autoPassiveIPSubstitution
- true if set to on, false otherwiseprotected void initStreams() throws IOException
IOException
public void close() throws IOException
IOException
public void logout() throws IOException
IOException
protected byte[] toByteArray(short value)
value
- value to convert
public void setActivePortRange(int lowest, int highest)
lowest
- lowest port number in rangehighest
- highest port number in rangeprotected void setDataPort(InetAddress host, short portNo) throws IOException, FTPException
host
- the local host the server will connect toportNo
- the port number to connect to
IOException
FTPException
protected FTPDataSocket createDataSocketPASV() throws IOException, FTPException
IOException
FTPException
protected FTPDataSocket newPassiveDataSocket(String remoteHost, int port) throws IOException
FTPDataSocket
object (client mode) and connect
to the given remote host and port number.
remoteHost
- Remote host to connect to.port
- Remote port to connect to.
FTPDataSocket
object (client mode) which is
connected to the given server.
IOException
- Thrown if no TCP/IP connection could be made.protected FTPDataSocket newActiveDataSocket(int port) throws IOException
FTPDataSocket
object (server mode) which will
listen on the given port number.
port
- Remote port to listen on.
FTPDataSocket
object (server mode) which is
configured to listen on the given port.
IOException
- Thrown if an error occurred when creating the socket.public FTPReply sendCommand(String command) throws IOException
command
- command to send
IOException
public FTPReply validateReply(String reply, String[] expectedReplyCodes) throws IOException, FTPException
reply
- the entire reply string we receivedexpectedReplyCodes
- array of expected replies
IOException
FTPException
public FTPReply validateReply(FTPReply reply, String[] expectedReplyCodes) throws FTPException
reply
- reply objectexpectedReplyCodes
- array of expected replies
FTPException
public FTPReply validateReply(FTPReply reply, String expectedReplyCode) throws FTPException
reply
- reply objectexpectedReplyCode
- expected reply
FTPException
|
edtFTPj | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |