日期:2014-05-20 浏览次数:20895 次
SocketAddress proxyAddress = new InetSocketAddress( "192.168.180.148" , 888 ) ; -- 内部网络的HTTP代理的IP 和端口 Proxy proxy = new Proxy( Proxy.Type.HTTP , proxyAddress ) ; Socket s = new Socket( proxy ) ; -------- 这个报错 s.setReuseAddress( true ) ; tcpclientSocketChannel = s.getChannel().open() ; this.tcpclientSocketChannel.connect( new InetSocketAddress( 外部网络的IP 和端口 ) ) ;
public void run() { SocketAddress addr = new InetSocketAddress("XXX.XXX.com",8080); Proxy proxy = new Proxy(Proxy.Type.HTTP, addr); for (int i = 0; i < 100; i++) { // InputStream input = new URL("http://XXXXXX/XXX/XXX").openConnection().getInputStream(); try { URL baseURL = new URL(address); HttpURLConnection uc = (HttpURLConnection) baseURL.openConnection(proxy); uc.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2"); InputStream input = uc.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } }