Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.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
请求新tor标识的Java telnet连接_Java_Sockets_Connection_Telnet_Tor - Fatal编程技术网

请求新tor标识的Java telnet连接

请求新tor标识的Java telnet连接,java,sockets,connection,telnet,tor,Java,Sockets,Connection,Telnet,Tor,我正在尝试使用telnet为tor请求新身份。据我所知,你应该 authenticate "" 然后,如果响应为“250 OK”,则发送 使用这段代码,我得到了一个“null”响应。我还使用了几个telnet客户端库,得到了相同的结果 try { Socket socket = new Socket("localhost", 9050); PrintWriter out = new PrintWriter(socket.getOutputStream(), tr

我正在尝试使用telnet为tor请求新身份。据我所知,你应该

authenticate ""
然后,如果响应为“250 OK”,则发送

使用这段代码,我得到了一个“null”响应。我还使用了几个telnet客户端库,得到了相同的结果

try {
        Socket socket = new Socket("localhost", 9050);
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        out.println("authenticate \"\"");
        System.out.println(in.readLine()); //should be 250 but is null

        out.close();
        in.close();
        socket.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

文档中说,所有命令都区分大小写。因此,您应该以
大写
的形式发送它们(根据文档)

我还发现一个有效的新身份请求

AUTHENTICATE
250 OK
SIGNAL NEWNYM
250 OK

希望有帮助

您没有服务器套接字。要接收telnet,您应该有服务器套接字。@Iman我试图添加ServerSocket ServerSocket=新的ServerSocket(端口号);但我不确定我应该做什么。如果我设置为9050,端口已经绑定到tor。如果我试着将其设置为9051,它就会卡在Socket=serverSocket.accept()上;
AUTHENTICATE
250 OK
SIGNAL NEWNYM
250 OK