public int getServerPort ( ) { String host = null ; CharSequence rawHost ; if ( ( rawHost = getHost ( ) ) != null ) { int length = rawHost . length ( ) ; int i ; for ( i = length - 1 ; i >= 0 ; i -- ) { if ( rawHost . charAt ( i ) == ' ' ) { int port = 0 ; for ( i ++ ; i < length ; i ++ ) { char ch = rawHost . charAt ( i ) ; if ( ' ' <= ch && ch <= ' ' ) { port = 10 * port + ch - ' ' ; } } return port ; } } // server/0521 vs server/052o // because of proxies, need to use the host header, // not the actual port return isSecure ( ) ? 443 : 80 ; } if ( host == null ) { return connTcp ( ) . portLocal ( ) ; } int p1 = host . lastIndexOf ( ' ' ) ; if ( p1 < 0 ) return isSecure ( ) ? 443 : 80 ; else { int length = host . length ( ) ; int port = 0 ; for ( int i = p1 + 1 ; i < length ; i ++ ) { char ch = host . charAt ( i ) ; if ( ' ' <= ch && ch <= ' ' ) { port = 10 * port + ch - ' ' ; } } return port ; } }
Returns the server s port .