connect(host, port = FTP_PORT)
  public
  
    
    
Establishes an FTP connection to host, optionally overriding the default
port. If the environment variable SOCKS_SERVER is set, sets up the
connection through a SOCKS proxy. Raises an exception (typically
Errno::ECONNREFUSED) if the connection cannot be established.
   
  
    Show source    
    
      
    def connect(host, port = FTP_PORT)
      if @debug_mode
        print "connect: ", host, ", ", port, "\n"
      end
      synchronize do
        @host = host
        @bare_sock = open_socket(host, port)
        @sock = BufferedSocket.new(@bare_sock, read_timeout: @read_timeout)
        voidresp
        if @ssl_context
          begin
            voidcmd("AUTH TLS")
            ssl_sock = start_tls_session(@bare_sock)
            @sock = BufferedSSLSocket.new(ssl_sock, read_timeout: @read_timeout)
            if @private_data_connection
              voidcmd("PBSZ 0")
              voidcmd("PROT P")
            end
          rescue OpenSSL::SSL::SSLError, OpenTimeout
            @sock.close
            raise
          end
        end
      end
    end