* @param targetHost the target host
* @param targetPort the target port
* @throws IOException if an exception occurs
*/
public static void establishTcpTunnel(IHttpConnection httpConnection, String targetHost, int targetPort) throws IOException {
INonBlockingConnection forwardCon = new NonBlockingConnection(targetHost, targetPort);
INonBlockingConnection tcpCon = httpConnection.getUnderlyingTcpConnection();
forwardCon.setAttachment(tcpCon);
tcpCon.setAttachment(forwardCon);
forwardCon.setFlushmode(FlushMode.ASYNC);
forwardCon.setAutoflush(false);
tcpCon.setFlushmode(FlushMode.ASYNC);
tcpCon.setAutoflush(false);
forwardCon.setHandler(new TcpProxyHandler());
tcpCon.setHandler(new TcpProxyHandler());
}