public class FTPControlSocket
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
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 StreamSocket |
controlSock
The underlying socket.
|
static java.lang.String |
cvsId
Revision control id
|
protected DataChannelCallback |
dataChannelCallback
Pasv callback method
|
protected static java.lang.String |
EPSV_END
End of PASV reply in IPv6
|
protected static java.lang.String |
EPSV_START
Start of PASV reply in IPv6
|
protected java.lang.String |
forcedActiveIP
IP address we force PORT to send - useful with certain
NAT configurations
|
protected boolean |
listenOnAllInterfaces
Listen to all interfaces in active mode
|
static int |
MAX_ACTIVE_RETRY
Maximum number of auto retries in active mode
|
protected java.io.Reader |
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
|
Modifier | Constructor and Description |
---|---|
protected |
FTPControlSocket(java.net.InetAddress remoteAddr,
int controlPort,
int timeout,
java.lang.String encoding,
FTPMessageListener messageListener)
Constructor.
|
protected |
FTPControlSocket(java.net.InetAddress remoteAddr,
StreamSocket controlSock,
int timeout,
java.lang.String encoding,
FTPMessageListener messageListener)
Constructs a new
FTPControlSocket using the given
Socket object. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the socket
|
protected com.enterprisedt.net.ftp.internal.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.
|
protected boolean |
isIPV6(java.net.InetAddress host)
Is this an IPV6 InetAddress?
|
boolean |
isSecureMode()
Is this socket in secure mode?
|
void |
logout()
Quit this FTP session and clean up.
|
protected com.enterprisedt.net.ftp.internal.FTPDataSocket |
newActiveDataSocket(int port)
Constructs a new
FTPDataSocket object (server mode) which will
listen on the given port number. |
protected com.enterprisedt.net.ftp.internal.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,
int portNo)
Sets the data port on the server, that is, sends a PORT
command.
|
protected byte[] |
toByteArray(int value)
Convert a short into a byte array
|
protected boolean |
usingProxy() |
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.
|
public static final java.lang.String cvsId
public static final int MAX_ACTIVE_RETRY
public static final int CONTROL_PORT
protected static final java.lang.String EPSV_START
protected static final java.lang.String EPSV_END
protected boolean listenOnAllInterfaces
protected StreamSocket controlSock
protected java.io.Writer writer
protected java.io.Reader reader
protected java.lang.String forcedActiveIP
protected java.net.InetAddress remoteAddr
protected boolean autoPassiveIPSubstitution
protected DataChannelCallback dataChannelCallback
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 messagesjava.io.IOException
FTPException
protected FTPControlSocket(java.net.InetAddress remoteAddr, StreamSocket 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 messagesjava.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.protected void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
autoPassiveIPSubstitution
- true if set to on, false otherwiseprotected void initStreams() throws java.io.IOException
java.io.IOException
public boolean isSecureMode()
public void close() throws java.io.IOException
java.io.IOException
public void logout() throws java.io.IOException
java.io.IOException
protected byte[] toByteArray(int value)
value
- value to convertpublic void setActivePortRange(int lowest, int highest)
lowest
- lowest port number in rangehighest
- highest port number in rangeprotected void setDataPort(java.net.InetAddress host, int portNo) throws java.io.IOException, FTPException
host
- the local host the server will connect toportNo
- the port number to connect tojava.io.IOException
FTPException
protected com.enterprisedt.net.ftp.internal.FTPDataSocket createDataSocketPASV() throws java.io.IOException, FTPException
java.io.IOException
FTPException
protected boolean usingProxy()
protected com.enterprisedt.net.ftp.internal.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 com.enterprisedt.net.ftp.internal.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, java.io.IOException, FTPException
command
- command to sendIOException,
- FTPExceptionjava.io.IOException
FTPException
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 repliesjava.io.IOException
FTPException
public FTPReply validateReply(FTPReply reply, java.lang.String[] expectedReplyCodes) throws FTPException
reply
- reply objectexpectedReplyCodes
- array of expected repliesFTPException
public FTPReply validateReply(FTPReply reply, java.lang.String expectedReplyCode) throws FTPException
reply
- reply objectexpectedReplyCode
- expected replyFTPException
protected boolean isIPV6(java.net.InetAddress host)
host
- InetAddress to testCopyright © 2001-2014 Enterprise Distributed Technologies Ltd. All Rights Reserved.