I tried to connect to a server through a SOCKS server in an Android client app (Android OS 1.5 and 1.6) with below snippet code:
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(Constants.SOCKS_PROXY_HOST, Constants.SOCKS_PROXY_PORT));
socket = new Socket(proxy);
InetSocketAddress dest = new InetSocketAddress(targetHost,targetPort);
socket.connect(dest);
However it gave out an exception on the last line:
W/System.err( 507): java.net.SocketException: SOCKS connection failed: java.net.SocketException: Bad socket
W/System.err( 507): at org.apache.harmony.luni.net.PlainSocketImpl.socksConnect(PlainSocketImpl.java:389)
W/System.err( 507): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:224)
W/System.err( 507): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:521)
W/System.err( 507): at java.net.Socket.connect(Socket.java:1019)
W/System.err( 507): at java.net.Socket.connect(Socket.java:960)
Anyone might have an idea where did i do wrong? Thanks in advance.