Code example for HttpHost

Methods: getHostName, getPort

0
    static HttpHost getSocksProxy(final HttpParams parameters) {
        return (HttpHost) parameters.getParameter(SOCKS_PROXY);
    } 
 
    static Socket createSocketWithSocksProxy(final HttpHost socksProxy) {
        final InetSocketAddress address = new InetSocketAddress(socksProxy.getHostName(), socksProxy.getPort());
        final Proxy proxy = new Proxy(Proxy.Type.SOCKS, address);
        return new Socket(proxy);
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public Socket createSocket(final HttpParams params) {
        final HttpHost socksProxy = getSocksProxy(params);
        if (socksProxy != null) {
            return createSocketWithSocksProxy(socksProxy);
        } 
        return super.createSocket(params);
    }