Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/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
Java读套接字Tcp更快_Java_Sockets_Tcp - Fatal编程技术网

Java读套接字Tcp更快

Java读套接字Tcp更快,java,sockets,tcp,Java,Sockets,Tcp,我运行这段代码,它是好的,但我得到了一个输出大约每5秒或更多(就像它被阻止),而它应该是每秒多次;线的大小(dati)是可变的 Socket clientSocket = new Socket("localhost", 5333); PrintStream wr = new PrintStream(clientSocket.getOutputStream()); wr.println("sub"); InputStreamReader ir = new InputStreamReader(

我运行这段代码,它是好的,但我得到了一个输出大约每5秒或更多(就像它被阻止),而它应该是每秒多次;线的大小(dati)是可变的

Socket clientSocket = new Socket("localhost", 5333); 
PrintStream wr = new PrintStream(clientSocket.getOutputStream()); 
wr.println("sub"); 
InputStreamReader ir = new InputStreamReader(clientSocket.getInputStream());
BufferedReader br = new BufferedReader(ir); 
String dati;
while ((dati = br.readLine()) != null){  
    System.out.println(dati); 
}

它被封锁了。正在等待发件人的数据。您的读取速度不能超过发送方发送的速度。

我想知道,如果没有发送行终止符,最终一些内部缓冲区被填满,会发生什么情况?