|
||||||||||
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 java.net.Socket |
controlSock
The underlying socket. |
static java.lang.String |
cvsId
Revision control id |
protected java.lang.String |
forcedActiveIP
IP address we force PORT to send - useful with certain NAT configurations |
protected java.io.BufferedReader |
reader
The reader that reads control data from the control socket |
protected java.net.InetAddress |
remoteAddr
The remote address to connect to |
protected java.io.Writer |
writer
The write that writes to the control socket |
Constructor Summary | |
---|---|
protected |
FTPControlSocket(java.net.InetAddress remoteAddr,
int controlPort,
int timeout,
java.lang.String encoding,
FTPMessageListener messageListener)
Constructor. |
protected |
FTPControlSocket(java.net.InetAddress remoteAddr,
java.net.Socket controlSock,
int timeout,
java.lang.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(java.lang.String remoteHost,
int port)
Constructs a new FTPDataSocket object (client mode) and connect
to the given remote host and port number. |
FTPReply |
sendCommand(java.lang.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(java.net.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,
java.lang.String expectedReplyCode)
Validate the response the host has supplied against the expected reply. |
FTPReply |
validateReply(FTPReply reply,
java.lang.String[] expectedReplyCodes)
Validate the response the host has supplied against the expected reply. |
FTPReply |
validateReply(java.lang.String reply,
java.lang.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 java.lang.String cvsId
public static final int CONTROL_PORT
protected java.net.Socket controlSock
protected java.io.Writer writer
protected java.io.BufferedReader reader
protected java.lang.String forcedActiveIP
protected java.net.InetAddress remoteAddr
protected boolean autoPassiveIPSubstitution
Constructor Detail |
---|
protected FTPControlSocket(java.net.InetAddress remoteAddr, int controlPort, int timeout, java.lang.String encoding, FTPMessageListener messageListener) throws java.io.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
java.io.IOException
FTPException
protected FTPControlSocket(java.net.InetAddress remoteAddr, java.net.Socket controlSock, int timeout, java.lang.String encoding, FTPMessageListener messageListener) throws java.io.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
java.io.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 java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public void logout() throws java.io.IOException
java.io.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(java.net.InetAddress host, short portNo) throws java.io.IOException, FTPException
host
- the local host the server will connect toportNo
- the port number to connect to
java.io.IOException
FTPException
protected FTPDataSocket createDataSocketPASV() throws java.io.IOException, FTPException
java.io.IOException
FTPException
protected FTPDataSocket newPassiveDataSocket(java.lang.String remoteHost, int port) throws java.io.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.
java.io.IOException
- Thrown if no TCP/IP connection could be made.protected FTPDataSocket newActiveDataSocket(int port) throws java.io.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.
java.io.IOException
- Thrown if an error occurred when creating the socket.public FTPReply sendCommand(java.lang.String command) throws java.io.IOException
command
- command to send
java.io.IOException
public FTPReply validateReply(java.lang.String reply, java.lang.String[] expectedReplyCodes) throws java.io.IOException, FTPException
reply
- the entire reply string we receivedexpectedReplyCodes
- array of expected replies
java.io.IOException
FTPException
public FTPReply validateReply(FTPReply reply, java.lang.String[] expectedReplyCodes) throws FTPException
reply
- reply objectexpectedReplyCodes
- array of expected replies
FTPException
public FTPReply validateReply(FTPReply reply, java.lang.String expectedReplyCode) throws FTPException
reply
- reply objectexpectedReplyCode
- expected reply
FTPException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |