Could you explain some more about using SocketFactory, please?
I try to modify ClientExecuteDirect for using socks proxy.
.........
SchemeRegistry supportedSchemes = new SchemeRegistry();
PlainSocketFactory sf = PlainSocketFactory.getSocketFactory();
// prepare parameters
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUseExpectContinue(params, false);
supportedSchemes.register(new Scheme("http", sf, 80));
String proxyHost = "localhost";
int proxyPort = 1080;
SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr);
Socket socket = new Socket(proxy);
try {
sf.connectSocket(socket,proxyHost, proxyPort, null, -1, params);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
ClientConnectionManager connMgr = new
ThreadSafeClientConnManager(params,
supportedSchemes);
DefaultHttpClient httpclient = new DefaultHttpClient(connMgr, params);
HttpGet req = new HttpGet("http://192.168.1.1/");
HttpResponse rsp = null;
try {
rsp = httpclient.execute(req);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
HttpEntity entity = rsp.getEntity();
....
So, I've got 2 different connections. First is connection to socks
proxy and second to http server, but not through proxy. Where is my
mistake?
Sorry, but I couldn't found any examples with using SocketFactory with
custom socket.
Any help will be appreciated!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]