Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.enterprisedt.net.ftp
Class FTPControlSocket

    java.lang.Object
      com.enterprisedt.net.ftp.FTPControlSocket

    public class FTPControlSocket

extends java.lang.Object

Supports client-side FTP operations

Version:
  $Revision: 1.57 $
Author:
  Bruce Blackshaw

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 StreamSocket` | `controlSock` The underlying socket.
`static java.lang.String` | `cvsId` Revision control id
`protected DataChannelCallback` | `dataChannelCallback` Pasv callback method
`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

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, StreamSocket 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 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.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cvsId

    public static final java.lang.String cvsId

  Revision control id

  See Also:
    Constant Field Values

### MAX_ACTIVE_RETRY

    public static final int MAX_ACTIVE_RETRY

  Maximum number of auto retries in active mode

  See Also:
    Constant Field Values

### CONTROL_PORT

    public static final int CONTROL_PORT

  The default and standard control port number for FTP

  See Also:
    Constant Field Values

### listenOnAllInterfaces

    protected boolean listenOnAllInterfaces

  Listen to all interfaces in active mode

### controlSock

    protected StreamSocket controlSock

  The underlying socket.

### writer

    protected java.io.Writer writer

  The write that writes to the control socket

### reader

    protected java.io.Reader reader

  The reader that reads control data from the control socket

### forcedActiveIP

    protected java.lang.String forcedActiveIP

  IP address we force PORT to send - useful with certain NAT configurations

### remoteAddr

    protected java.net.InetAddress remoteAddr

  The remote address to connect to

### autoPassiveIPSubstitution

    protected boolean autoPassiveIPSubstitution

  If true, uses the original host IP if an internal IP address is returned by the server in PASV mode

### dataChannelCallback

    protected DataChannelCallback dataChannelCallback

  Pasv callback method

Constructor Detail

### FTPControlSocket

    protected FTPControlSocket(java.net.InetAddress remoteAddr,
                               int controlPort,
                               int timeout,
                               java.lang.String encoding,
                               FTPMessageListener messageListener)
                        throws java.io.IOException,
                               FTPException

  Constructor. Performs TCP connection and sets up reader/writer. Allows different control port to be used

  Parameters:
    `remoteAddr` - Remote inet address
    `controlPort` - port for control stream
    `timeout` - the length of the timeout, in milliseconds
    `encoding` - character encoding used for data
    `messageListener` - listens for messages
  Throws:
    `java.io.IOException`
    `FTPException`

### FTPControlSocket

    protected FTPControlSocket(java.net.InetAddress remoteAddr,
                               StreamSocket controlSock,
                               int timeout,
                               java.lang.String encoding,
                               FTPMessageListener messageListener)
                        throws java.io.IOException,
                               FTPException

  Constructs a new `FTPControlSocket` using the given `Socket` object.

  Parameters:
    `remoteAddr` - the remote address
    `controlSock` - Socket to be used.
    `timeout` - Timeout to be used.
    `encoding` - character encoding used for data
    `messageListener` - listens for messages
  Throws:
    `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

### setAutoPassiveIPSubstitution

    protected void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)

  Set automatic substitution of the remote host IP on if in passive mode

  Parameters:
    `autoPassiveIPSubstitution` - true if set to on, false otherwise

### initStreams

    protected void initStreams()
                        throws java.io.IOException

  Initialize the reader/writer streams for this connection.

  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Close the socket

  Throws:
    `java.io.IOException`

### logout

    public void logout()
                throws java.io.IOException

  Quit this FTP session and clean up.

  Throws:
    `java.io.IOException`

### toByteArray

    protected byte[] toByteArray(int value)

  Convert a short into a byte array

  Parameters:
    `value` - value to convert
  Returns:
    a byte array

### setActivePortRange

    public void setActivePortRange(int lowest,
                                   int highest)

  Set the port number range for active mode

  Parameters:
    `lowest` - lowest port number in range
    `highest` - highest port number in range

### setDataPort

    protected void setDataPort(java.net.InetAddress host,
                               int portNo)
                        throws java.io.IOException,
                               FTPException

  Sets the data port on the server, that is, sends a PORT command.

  Parameters:
    `host` - the local host the server will connect to
    `portNo` - the port number to connect to
  Throws:
    `java.io.IOException`
    `FTPException`

### createDataSocketPASV

    protected com.enterprisedt.net.ftp.internal.FTPDataSocket createDataSocketPASV()
                                                                            throws java.io.IOException,
                                                                                   FTPException

  Request a data socket be created on the server, connect to it and return our connected socket.

  Returns:
    connected data socket
  Throws:
    `java.io.IOException`
    `FTPException`

### usingProxy

    protected boolean usingProxy()

### newPassiveDataSocket

    protected com.enterprisedt.net.ftp.internal.FTPDataSocket newPassiveDataSocket(java.lang.String remoteHost,
                                                                                   int port)
                                                                            throws java.io.IOException

  Constructs a new `FTPDataSocket` object (client mode) and connect to the given remote host and port number.

  Parameters:
    `remoteHost` - Remote host to connect to.
    `port` - Remote port to connect to.
  Returns:
    A new `FTPDataSocket` object (client mode) which is connected to the given server.
  Throws:
    `java.io.IOException` - Thrown if no TCP/IP connection could be made.

### newActiveDataSocket

    protected com.enterprisedt.net.ftp.internal.FTPDataSocket newActiveDataSocket(int port)
                                                                           throws java.io.IOException

  Constructs a new `FTPDataSocket` object (server mode) which will listen on the given port number.

  Parameters:
    `port` - Remote port to listen on.
  Returns:
    A new `FTPDataSocket` object (server mode) which is configured to listen on the given port.
  Throws:
    `java.io.IOException` - Thrown if an error occurred when creating the socket.

### sendCommand

    public FTPReply sendCommand(java.lang.String command)
                         throws java.io.IOException,
                                java.io.IOException,
                                FTPException

  Send a command to the FTP server and return the server's reply as a structured reply object

  Parameters:
    `command` - command to send
  Returns:
    reply to the supplied command
  Throws:
    `IOException,` - FTPException
    `java.io.IOException`
    `FTPException`

### validateReply

    public FTPReply validateReply(java.lang.String reply,
                                  java.lang.String[] expectedReplyCodes)
                           throws java.io.IOException,
                                  FTPException

  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
    `expectedReplyCodes` - array of expected replies
  Returns:
    an object encapsulating the server's reply
  Throws:
    `java.io.IOException`
    `FTPException`

### validateReply

    public FTPReply validateReply(FTPReply reply,
                                  java.lang.String[] expectedReplyCodes)
                           throws FTPException

  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
    `expectedReplyCodes` - array of expected replies
  Returns:
    reply object
  Throws:
    `FTPException`

### validateReply

    public FTPReply validateReply(FTPReply reply,
                                  java.lang.String expectedReplyCode)
                           throws FTPException

  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
    `expectedReplyCode` - expected reply
  Returns:
    reply object
  Throws:
    `FTPException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2001-2007 Enterprise Distributed Technologies Ltd. All Rights Reserved.