Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与TorJava的连接_Java_Tor_Silvertunnel - Fatal编程技术网

与TorJava的连接

与TorJava的连接,java,tor,silvertunnel,Java,Tor,Silvertunnel,我在看图书馆,但努力建立一个成功的联系。我遇到的问题是,连接需要超过10分钟才能给出输出。我正在查看他们的一个,这是我的代码: public boolean tryConnOLD() throws IOException { try { // define remote address String remoteHostname = "http://test.silvertunnel.com"; int remotePort = 80;

我在看图书馆,但努力建立一个成功的联系。我遇到的问题是,连接需要超过10分钟才能给出输出。我正在查看他们的一个,这是我的代码:

public boolean tryConnOLD() throws IOException {

    try {
        // define remote address
        String remoteHostname = "http://test.silvertunnel.com";
        int remotePort = 80;
        TcpipNetAddress remoteAddress = new TcpipNetAddress(remoteHostname, remotePort);
        // get TorNetLayer instance and wait until it is ready
        NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
        netLayer.waitUntilReady();
        // open connection to remote address - this connection is tunneled through the TOR anonymity network
        netSocket = netLayer.createNetSocket(null, null, remoteAddress);
        InputStream is = netSocket.getInputStream();

        String content = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
        Closeables.closeQuietly(is);

        is.close();
        System.out.println(is.read());
        java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");

        if(s.hasNext()) {
         System.out.println(s.next());   
         System.out.println();   
        }

        return true;

    } catch (IOException ex) {

    } finally {
        netSocket.close();
    }

    return false;
}

问题很简单,当您使用silvertunnel API时,不需要在url中指定协议,因此只需删除
http://
即可修复错误

试试下面的方法

                        //remove http://   
String remoteHostname = "test.silvertunnel.com";

Tor在大多数情况下都很慢。确保运行TOR节点,以保持网络活动!