I have a need to connect to a server via telnet via a proxy:

Here is my code:


TelnetClient telnet;

telnet = new TelnetClient();

SSLSocketFactory sslsocketfactory = (SSLSocketFactory) 
SSLSocketFactory.getDefault();
telnet.setSocketFactory(sslsocketfactory);

Proxy socksProxy  = new Proxy(Proxy.Type.SOCKS, new 
InetSocketAddress("127.0.0.1", 6600));
telnet.setProxy(socksProxy);

telnet.connect(host, port);


When I run this code, no errors are thrown, but the reader thread blocks. When 
I debug the program, I noticed that the Telnet negotiation did not fire.
When I debugged a little further, I noticed that when I set the proxy, the code 
in SocketClient.setProxy() resets the socket client.

I downloaded the Apache code and commented out the line

   /**
     * Sets the proxy for use with all the connections.
     * The proxy is used for connections established after the
     * call to this method.
     *
     * @param proxy the new proxy for connections.
     * @since 3.2
     */
    public void setProxy(Proxy proxy) {
       // setSocketFactory(new DefaultSocketFactory(proxy));
        connProxy = proxy;
    }

My code then works.

Is this a bug, or am I using the TelnetClient incorrectly?

Regards John Holliday

This E-Mail is intended only for the addressee. Its use is limited to that 
intended by the author at the time and it is not to be distributed without the 
author's consent. Unless otherwise stated, the State of Queensland accepts no 
liability for the contents of this E-Mail except where subsequently confirmed 
in writing. The opinions expressed in this E-Mail are those of the author and 
do not necessarily represent the views of the State of Queensland. This E-Mail 
is confidential and may be subject to a claim of legal privilege. If you have 
received this E-Mail in error, please notify the author and delete this message 
immediately.

Reply via email to