Skip to content
FutureBlitz

    Install

    Import std.net.ipc

    IpcStream

    std.net.ipc

    class

    Public Class IpcStream Implements Reader, Writer

    A connection to an IpcListener: bytes both ways, in order, which it reads and writes as std.io's streams do. A Read or Write that fails throws an IOError whose Cause is a NetError or a TimeoutError. It closes when it goes, or at Close, which the other side reads as its end. A named pipe can't end one way only, so it has no ShutdownWrite, as a TcpStream has.

    Examples

    Local stream = Try IpcStream.Connect("example-app")
    Try stream.WriteText("hello")
    Print(Try ReadAllText(stream))
    stream.Close()

    std/net/ipc.fb, line 36

    • @PanicsAtCaller Public Static Method Connect(name: String, timeout: Duration? = Null): IpcStream Throws NetError, TimeoutError static method #

      Connects to the IpcListener of name, waiting up to timeout, or as long as it takes for a Null one. Throws a NetError of REFUSED when nothing listens at it, and a TimeoutError when it takes too long. A name that isn't one panics.

    • @PanicsAtCaller Public Static Async Method ConnectAsync(name: String, timeout: Duration? = Null): IpcStream Throws NetError, TimeoutError static method #

      Connect's Async twin, which waits on the main thread.

    • Public Property Name: String property #

      The name of the listener it's connected to, or that it came to.

    • Public Property ReadTimeout: Duration? property #

      How long a Read or ReadAsync waits for bytes before it throws, or Null, as it starts, to wait as long as it takes.

    • Public Property IsClosed: Bool property #

      Whether Close closed it.

    • Public Method Read(into: Buffer<UInt8>): Int64 Throws IOError method #

      Reads what's come, at least a byte, waiting for some, or 0 once the other side ended what it writes.

    • Public Async Method ReadAsync(into: Buffer<UInt8>): Int64 Throws IOError method #

      Read's Async twin, which waits on the I/O thread for the connection's bytes while the main thread goes on.

    • Public Method Write(from: Buffer<UInt8>) Throws IOError method #

      Writes all of from's bytes, returning once the OS has them.

    • Public Async Method WriteAsync(from: Buffer<UInt8>) Throws IOError method #

      Write's Async twin, which waits on the I/O thread while the connection's bytes go, while the main thread goes on.

    • Public Method Close() method #

      Closes it at once: a Read or Write waiting for it throws an IOError whose Cause is a NetError of CLOSED, and so does one after. Going closes it too.

    Report an issue with this page or with FutureBlitz on GitHub.