mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 03:41:15 +01:00
Net-client: perf tuning - make read buf the size of socket receive buf
This commit is contained in:
@@ -219,7 +219,15 @@ public class Client implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
byte[] readBuffer = new byte[2048]; // Ethernet MTU = 1500 B
|
||||
byte[] readBuffer;
|
||||
{ // make the read buffer same size as socket receive buffer so that
|
||||
// we don't waste cycles calling listeners when there is more data waiting
|
||||
int readBufferSize = 2 << 16; // 64 KB (default socket receive buffer size)
|
||||
try {
|
||||
readBufferSize = socket.getReceiveBufferSize();
|
||||
} catch (SocketException ignore) { }
|
||||
readBuffer = new byte[readBufferSize];
|
||||
}
|
||||
while (Thread.currentThread() == thread) {
|
||||
try {
|
||||
while (input != null) {
|
||||
|
||||
Reference in New Issue
Block a user