'input2ipc' and 'fromipc' handle multiple messages.

tmp
Philippe Pittoli 2023-05-15 15:46:04 +02:00
parent 39fc84934d
commit d187d02de7
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,7 @@
# Read an IPC network packet and remove the first 4 bytes. # Read an IPC network packet and remove the first 4 bytes.
buffer = Bytes.new 1_000_000 buffer = Bytes.new 1_000_000
len = STDIN.read buffer while true
STDOUT.write buffer[4.. len -1] len = STDIN.read buffer
break if len == 0
STDOUT.write buffer[4.. len -1]
end

View File

@ -2,6 +2,7 @@
buffer = Bytes.new 1_000_000 buffer = Bytes.new 1_000_000
while true while true
len = STDIN.read buffer len = STDIN.read buffer
break if len == 0
STDOUT.write_bytes len, IO::ByteFormat::BigEndian STDOUT.write_bytes len, IO::ByteFormat::BigEndian
STDOUT.write buffer[0.. len -1] STDOUT.write buffer[0.. len -1]
end end