diff options
Diffstat (limited to 'clientserver/src/mill/clientserver/ClientServer.scala')
-rw-r--r-- | clientserver/src/mill/clientserver/ClientServer.scala | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clientserver/src/mill/clientserver/ClientServer.scala b/clientserver/src/mill/clientserver/ClientServer.scala index a7de2ba3..9ca3a138 100644 --- a/clientserver/src/mill/clientserver/ClientServer.scala +++ b/clientserver/src/mill/clientserver/ClientServer.scala @@ -103,16 +103,21 @@ class ProxyInputStream(x: => java.io.InputStream) extends java.io.InputStream{ override def read(b: Array[Byte]) = x.read(b) } -class ClientInputPumper(src: InputStream, dest: OutputStream) extends Runnable{ +class ClientInputPumper(src: InputStream, + dest: OutputStream, + checkAvailable: Boolean = false) extends Runnable{ var running = true def run() = { val buffer = new Array[Byte](1024) while(running){ - val n = src.read(buffer) - if (n == -1) running = false + if (checkAvailable && src.available() == 0) Thread.sleep(2) else { - dest.write(buffer, 0, n) - dest.flush() + val n = src.read(buffer) + if (n == -1) running = false + else { + dest.write(buffer, 0, n) + dest.flush() + } } } } |