Code example for InetSocketAddress

Methods: getAddressgetHostNamegetPortisUnresolved

                throw new HttpException
                    ("Unable to handle non-Inet proxy address: "+p.address());
            final InetSocketAddress isa = (InetSocketAddress) p.address();
            // assume default scheme (http) 
            result = new HttpHost(getHost(isa), isa.getPort());
        return result;
     * Obtains a host from an {@link InetSocketAddress}. 
     * @param isa       the socket address 
     * @return  a host string, either as a symbolic name or 
     *          as a literal IP address string 
     * <br/> 
     * (TODO: determine format for IPv6 addresses, with or without [brackets]) 
    protected String getHost(InetSocketAddress isa) {
        //@@@ Will this work with literal IPv6 addresses, or do we 
        //@@@ need to wrap these in [] for the string representation? 
        //@@@ Having it in this method at least allows for easy workarounds. 
       return isa.isUnresolved() ?
            isa.getHostName() : isa.getAddress().getHostAddress();
     * Chooses a proxy from a list of available proxies.