According to the Apache official JAVAAPI, the agent should be created as follows
Socket socket = new socket (new Proxy (Proxy.type.socks,new inetsocketaddress ("10.161.32.26", 8080));
try {
Socket.connect (New Inetsocketaddress ("http://www.baidu.com", 80));
System.out.println (socket.isconnected ());
catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
10.161.32.26 LAN Agent ip,8080 LAN proxy port
But unfortunately, this method I tried, rice useful, always error java.net.SocketException:Software caused connection Abort:recv failed;
Socket "If not in accordance with their own package under the" mode//The address is the proxy server's address socket socket = new Socket ("10.1.2.188", 80); Write and content is to follow the HTTP request protocol format content, request Baidu Socket.getoutputstream (). Write (New String ("Get http://www.baidu.com/http/1.1\r\n\r\ N "). GetBytes ()); byte [] bs = new byte [1024]; InputStream is = Socket.getinputstream (); int i; while ((i = Is.read (BS)) > 0) {System.out.println (New String (BS, 0, I));} is.close ();
Lazy, the rest of the direct send link
http://b-l-east.iteye.com/blog/1199237