From d187d02de72615ee6a51325606239ebfddb0505e Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 15 May 2023 15:46:04 +0200 Subject: [PATCH] 'input2ipc' and 'fromipc' handle multiple messages. --- crystal/src/fromipc.cr | 7 +++++-- crystal/src/input2ipc.cr | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crystal/src/fromipc.cr b/crystal/src/fromipc.cr index e2d9447..e411eec 100644 --- a/crystal/src/fromipc.cr +++ b/crystal/src/fromipc.cr @@ -1,4 +1,7 @@ # Read an IPC network packet and remove the first 4 bytes. buffer = Bytes.new 1_000_000 -len = STDIN.read buffer -STDOUT.write buffer[4.. len -1] +while true + len = STDIN.read buffer + break if len == 0 + STDOUT.write buffer[4.. len -1] +end diff --git a/crystal/src/input2ipc.cr b/crystal/src/input2ipc.cr index 80f9455..cbd4fb8 100644 --- a/crystal/src/input2ipc.cr +++ b/crystal/src/input2ipc.cr @@ -2,6 +2,7 @@ buffer = Bytes.new 1_000_000 while true len = STDIN.read buffer + break if len == 0 STDOUT.write_bytes len, IO::ByteFormat::BigEndian STDOUT.write buffer[0.. len -1] end