I am using HttpClient 4.02 to create a connection through a proxy (using the CONNECT method) to tunnel the connection to the remote server. HttpClient is very convenient for this, but I'm new to the API and can't see how to get to the underlying Sockettunneled connection.
The following code is taken from: http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
HttpHost target = new HttpHost("target.server.net", 443, "https");
HttpHost proxy = new HttpHost("some.proxy.net", 8080, "http");
SchemeRegistry supportedSchemes = new SchemeRegistry();
supportedSchemes.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
supportedSchemes.register(new Scheme("https",
SSLSocketFactory.getSocketFactory(), 443));
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
ClientConnectionManager ccm = new ThreadSafeClientConnManager(params,
supportedSchemes);
DefaultHttpClient httpclient = new DefaultHttpClient(ccm, params);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpGet req = new HttpGet("/");
System.out.println("executing request to " + target + " via " + proxy);
HttpResponse rsp = httpclient.execute(target, req);
HttpEntity entity = rsp.getEntity();
This sets up a connection fine, but is there a way to get the basic Socketone so that I can use my own protocol to communicate with the server on target.server.net?