服务器接收远程客户端命令..收到的命令被正确处理然后发送回客户端..但客户端无法读取输出,out.println中没有任何内容(" ServerMessage") ;
客户必须从服务器读取收到的数据..
有人可以帮忙吗?
谢谢!
SERVER:
String MsG2X90aXk11 = "";
Thread.sleep(100);
while ((MsG2X90aXk11 = ShellZ.readLine()) != null) {
BufferedWriter writeCommand = new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream()));
String message = MsG2X90aXk11;
writeCommand.write(message+"\n");
writeCommand.flush();
客户端:
BufferedReader in = null;
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
String m6x7NXaxn102 = null;
while ((m6x7NXaxn102 = in.readLine()) != null) {
System.out.println(m6x7NXaxn102);
}
答案 0 :(得分:0)
您正在尝试打印line
变量。从输入流中读取每一行的变量是m6x7NXaxn102
更改:
System.out.println(line);
致:
System.out.println(m6x7NXaxn102);
或:
更改:
while((m6x7NXaxn102 = in.readLine()) != null)
致:
while((line = in.readLine()) != null)
希望这会有所帮助。 :)