public HostPort setPassive ( ) throws IOException , ServerException { Reply reply = null ; try { reply = controlChannel . execute ( ( controlChannel . isIPv6 ( ) ) ? Command . EPSV : Command . PASV ) ; } catch ( UnexpectedReplyCodeException urce ) { throw ServerException . embedUnexpectedReplyCodeException ( urce ) ; } catch ( FTPReplyParseException rpe ) { throw ServerException . embedFTPReplyParseException ( rpe ) ; } String pasvReplyMsg = null ; pasvReplyMsg = reply . getMessage ( ) ; int openBracket = pasvReplyMsg . indexOf ( "(" ) ; int closeBracket = pasvReplyMsg . indexOf ( ")" , openBracket ) ; String bracketContent = pasvReplyMsg . substring ( openBracket + 1 , closeBracket ) ; this . session . serverMode = Session . SERVER_PASSIVE ; HostPort hp = null ; if ( controlChannel . isIPv6 ( ) ) { hp = new HostPort6 ( bracketContent ) ; // since host information might be null // fill it it if ( hp . getHost ( ) == null ) { ( ( HostPort6 ) hp ) . setVersion ( HostPort6 . IPv6 ) ; ( ( HostPort6 ) hp ) . setHost ( controlChannel . getHost ( ) ) ; } } else { hp = new HostPort ( bracketContent ) ; } this . session . serverAddress = hp ; return hp ; }
Sets remote server to passive server mode .