why the heck was this buffer so small?

This commit is contained in:
rusefi 2018-10-13 14:10:08 -04:00
parent 4fb92fe6fd
commit de8a79bfb8
1 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import com.rusefi.io.LinkManager;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Arrays;
/** /**
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
@ -51,13 +52,13 @@ public class TcpIoStream implements IoStream {
Thread.currentThread().setName("TCP connector loop"); Thread.currentThread().setName("TCP connector loop");
FileLog.MAIN.logLine("Running TCP connection loop"); FileLog.MAIN.logLine("Running TCP connection loop");
byte b[] = new byte[1]; byte inputBuffer[] = new byte[256];
while (true) { while (true) {
try { try {
int result = input.read(b); int result = input.read(inputBuffer);
if (result == -1) if (result == -1)
throw new IOException("TcpIoStream: End of input?"); throw new IOException("TcpIoStream: End of input?");
listener.onDataArrived(b); listener.onDataArrived(Arrays.copyOf(inputBuffer, result));
} catch (IOException e) { } catch (IOException e) {
System.err.println("TcpIoStream: End of connection"); System.err.println("TcpIoStream: End of connection");
return; return;