public void connect(String host, int port) throws IOException {
        if (host == null) {
            return;
        }
        if (debug > 0){
            error("connect(" + host + "," + port + ")");
        }
        try {
        	
        	String username = System.getProperty("telnet.username");
        	String password = System.getProperty("telnet.password");
            // Connect to the specified server
//            _telnet.connect(host, port);
    		conn = new Connection(host);
    			/*
    			 * CONNECT AND VERIFY SERVER HOST KEY (with callback)
    			 */

    			String[] hostkeyAlgos = database.getPreferredServerHostkeyAlgorithmOrder(host);
    
    			if (hostkeyAlgos != null)
    				conn.setServerHostKeyAlgorithms(hostkeyAlgos);

    			conn.connect(new AdvancedVerifier(database));

    			/*
    			 * AUTHENTICATION PHASE
    			 */

    			while (true) {
    	        	
    				if (conn.isAuthMethodAvailable(username, "password"))
    				{
    					boolean res = conn.authenticateWithPassword(username, password);

    					if (res == true)
    						break;

//    					lastError = "Password authentication failed."; // try again, if possible

    					continue;
    				}
//    				throw new IOException("No supported authentication methods available.");
    			}

//begin @sp 21.07.11 TEST     			
        } catch (Exception e) {
        	
        }
        try {
//end @sp 21.07.11 TEST 
    			/*
    			 * 
    			 * AUTHENTICATION OK. DO SOMETHING.
    			 * 
    			 */

    			session = conn.openSession();

    			int x_width = 85;
    			int y_width = 24;

    			session.requestPTY("dumb", x_width, y_width, 0, 0, null);
    			session.startShell();

//    			TerminalDialog td = new TerminalDialog(loginFrame, username + "@" + hostname, sess, x_width, y_width);

    			/* The following call blocks until the dialog has been closed */

//    			td.setVisible(true);
    			
//            // Get input and output stream references
//            _in = _telnet.getInputStream();
//            _out = _telnet.getOutputStream();
        	_in = new StreamGobbler(session.getStdout());
            _out = session.getStdin();
			online = true;
	        bus.broadcast(new OnlineStatus(online));
          
        } catch (Exception e) {
            error = "Sorry, Could not connect to: " + host + " " + port + "\r\n" + "Reason: " + e + "\r\n\r\n";
//begin add @sp 12.05.11 handle connection error
//begin del @sp 20.07.11 TEST: IGNORE ERROR MSG FROM SERVER           
//            JOptionPane.showMessageDialog(
//                    null, 
//                    "An error occurred while connecting to " + host + "\r\n" + "Reason: " + e.getMessage() + "\r\n\r\n", 
//                    "Connection Error", 
//                    JOptionPane.INFORMATION_MESSAGE);
//            disconnect();
//            System.exit(0);
//end del @sp 20.07.11 TEST: IGNORE ERROR MSG FROM SERVER     
//end add @sp 12.05.11 handle connection error 
        } 
    }