1
URL uri = null;
    try
    {
        uri = new URL(aURL);
    }
    catch (MalformedURLException e)
    {
        // TODO Auto-generated catch block
        Log.e("My SOCKET CONNECTION ERROR 1-->>", e.toString());
        e.printStackTrace();
    }

    InetSocketAddress sa = InetSocketAddress.createUnresolved("XXX.XXX.X.XXX", 1080);
    Proxy proxy = new Proxy(Proxy.Type.SOCKS, sa);
    try
    {
        HttpURLConnection conn = (HttpURLConnection) uri.openConnection(proxy);
        conn.connect();
    }
    catch (IOException e)
    {
        // TODO Auto-generated catch block
        Log.e("My SOCKET CONNECTION ERROR 2-->>", e.toString());

        e.printStackTrace();
    }  

这是我试图用我们的 IP 与 SOCKS 服务器连接的代码,但它给了我这个错误:

java.net.SocketException:recvfrom 失败:ECONNRESET(对等方重置连接)

为什么这没有连接到服务器?我的代码连接到 SOCKS 服务器是否有任何错误?

非常感谢你的帮助!

4

0 回答 0