rb.pipe opens a region of shared memory that the script and another process
both map, and passes messages through it in both directions. A script reaches
for it to talk to a companion program on the same PC.
Needs: the exec permission; Windows.
This script opens a pipe, sends one message, then checks for replies ten times a
second for five seconds:
rb.pipe.open(name: string, options: { size: number? }?) -> PipeHandle
open checks the exec permission first on every platform, then raises
Pipe is only supported on Windows on any platform but Windows.
The region is the Windows object Local\Rebind_<name>. name is 1 to 64 ASCII
letters, digits, - or _. size (default 65,536) is rounded up to a power of
two and clamped to 1,024 to 16 MiB. Opening a name the script already has open
raises Pipe '<name>' is already open.
After
close, read and write raise Pipe '<name>' is closed.
Wire protocol
The region holds two channels. The script writes channel A at offset0 and
reads channel B at offset size / 2; the other process does the reverse. Each
channel is a 12-byte header and the payload:
A writer stores the payload, then the length, then the sequence number. A reader
reads only when the sequence number changed since its last read. Each channel
holds one message: an unread message is overwritten by the next write.