Skip to content
FutureBlitz

    Install

    Import std.net.ipc

    IpcListener

    std.net.ipc

    class

    Public Class IpcListener

    Takes connections at a name, from programs on the same machine, which Accept gives as IpcStreams. It closes when it goes, or at Close, with the connections nothing accepted, and its name is free again, but on Windows, where a named pipe is there until its connections close too, both ends: a connection to it meanwhile waits, for up to 30 seconds.

    Examples

    Local listener = Try IpcListener.Listen("example-app")
    Local client = Try listener.Accept()
    Try client.WriteText("hello from the server")
    client.Close()

    std/net/ipc.fb, line 128

    • @PanicsAtCaller Public Static Method Listen(name: String, backlog: Int = BACKLOG): IpcListener Throws NetError static method #

      Listens at name: 1 to 64 ASCII letters, digits, '.', '-', and '_', or it panics, with a backlog of 1 at least. A name is the same whatever its letters' case, as Windows' named pipes are, so "App" and "app" are one name on every OS. Throws a NetError when something listens at it already. A Unix socket's file that a program left when it ended without closing its listener is taken over, and any other file there stays.

    • Public Property Name: String property #

      Where it listens.

    • Public Property IsClosed: Bool property #

      Whether Close closed it.

    • Public Method Accept(timeout: Duration? = Null): IpcStream Throws NetError, TimeoutError method #

      The next connection, waiting up to timeout for one, or as long as it takes for a Null one, and throwing a TimeoutError after.

    • Public Async Method AcceptAsync(timeout: Duration? = Null): IpcStream Throws NetError, TimeoutError method #

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

    • Public Method Close() method #

      Closes it at once, with the connections nothing accepted: what's waiting for it throws a NetError of CLOSED, and so does what uses it after. Going closes it too.

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