public String[] connect(String host,int port) throws IllegalStateException, IOException, FTPIllegalReplyException, FTPException {
synchronized (lock) {
    if (connected) {
      throw new IllegalStateException("Client already connected to " + host + " on port "+ port);
    }
    Socket connection=null;
    try {
      connection=connector.connectForCommunicationChannel(host,port);
      if (security == SECURITY_FTPS) {
        connection=ssl(connection,host,port);
      }
      communication=new FTPCommunicationChannel(connection,pickCharset());
      for (Iterator i=communicationListeners.iterator(); i.hasNext(); ) {
        communication.addCommunicationListener((FTPCommunicationListener)i.next());
      }
      FTPReply wm=communication.readFTPReply();
      if (!wm.isSuccessCode()) {
        throw new FTPException(wm);
      }
      this.connected=true;
      this.authenticated=false;
      this.parser=null;
      this.host=host;
      this.port=port;
      this.username=null;
      this.password=null;
      this.utf8Supported=false;
      this.restSupported=false;
      this.mlsdSupported=false;
      this.modezSupported=false;
      this.dataChannelEncrypted=false;
      return wm.getMessages();
    }
 catch (    IOException e) {
      throw e;
    }
 finally {
      if (!connected) {
        if (connection != null) {
          try {
            connection.close();
          }
 catch (          Throwable t) {
            ;
          }
        }
      }
    }
  }
}

public String [ ] connect ( String host , int port ) throws IllegalStateException , IOException , FTPIllegalReplyException , FTPException { synchronized ( lock ) { if ( connected ) { throw new IllegalStateException ( "Client already connected to " + host + " on port " + port ) ; } Socket connection = null ; try { connection = connector . connectForCommunicationChannel ( host , port ) ; if ( security == SECURITY_FTPS ) { connection = ssl ( connection , host , port ) ; } communication = new FTPCommunicationChannel ( connection , pickCharset ( ) ) ; for ( Iterator i = communicationListeners . iterator ( ) ; i . hasNext ( ) ; ) { communication . addCommunicationListener ( ( FTPCommunicationListener ) i . next ( ) ) ; } FTPReply wm = communication . readFTPReply ( ) ; if ( ! wm . isSuccessCode ( ) ) { throw new FTPException ( wm ) ; } this . connected = true ; this . authenticated = false ; this . parser = null ; this . host = host ; this . port = port ; this . username = null ; this . password = null ; this . utf8Supported = false ; this . restSupported = false ; this . mlsdSupported = false ; this . modezSupported = false ; this . dataChannelEncrypted = false ; return wm . getMessages ( ) ; } catch ( IOException e ) { throw e ; } finally { if ( ! connected ) { if ( connection != null ) { try { connection . close ( ) ; } catch ( Throwable t ) { ; } } } } } }
this method connects the client to the remote ftp host .
