我正在从 TCP 流媒体软件读取流数据。我目前正在使用 while 循环连续读取。但我不确定这是否是读取流数据的最佳技术。
以下是我目前正在使用的代码:
Socket client=new Socket("169.254.99.2",1234);
System.out.println("Client connected ");
//getting the o/p stream of that connection
PrintStream out=new PrintStream(client.getOutputStream());
out.print("Hello from client\n");
out.flush();
//reading the response using input stream
BufferedReader in= new BufferedReader(new InputStreamReader(client.getInputStream()));
int a = 1;
int b= 1;
//
while(a==b){
// I'm just printing it out.
System.out.println("Response" + in.read());
}
建议lz???