public boolean connect ( ) { if ( client . isConnected ( ) ) { logger . warn ( "Already connected" ) ; return true ; } try { logger . info ( "Connecting to remote host " + remoteHost ) ; client . connect ( remoteHost ) ; client . rlogin ( localUser , remoteUser , terminalType ) ; writer = new OutputStreamWriter ( client . getOutputStream ( ) ) ; outputReaderThread = new Thread ( new OutputReader ( ) ) ; outputReaderThread . start ( ) ; if ( interactive ) { standardInputReaderThread = new Thread ( new StandardInputReader ( ) ) ; standardInputReaderThread . start ( ) ; } try { Thread . sleep ( 200 ) ; } catch ( InterruptedException ex ) { } if ( client . isConnected ( ) ) { return true ; } else { logger . fatal ( "Client has been immediately disconnected from remote host:" + remoteHost ) ; return false ; } //outputReaderThread. } catch ( IOException e ) { logger . fatal ( "Could not connect to remote host:" + remoteHost , e ) ; return false ; } }
Create a rlogin connection to the specified remote host .