Import std.net.ipc
IpcListener
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()-
@PanicsAtCaller Public Static Method Listen(name: String, backlog: Int = BACKLOG): IpcListener Throws NetErrorstatic method #Listens at
name: 1 to 64 ASCII letters, digits, '.', '-', and '_', or it panics, with abacklogof 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. -
Where it listens.
-
Whether Close closed it.
-
The next connection, waiting up to
timeoutfor 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, TimeoutErrormethod #Accept's Async twin, which waits on the main thread.
-
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.