Import std.net.ipc
std.net.ipc
std.net's IPC: IpcListener, which takes connections at a name, and IpcStream, a connection's bytes both ways, between programs on one machine. libuv chooses what a name is: a named pipe, \.\pipe<name>, on Windows, and a Unix socket, .sock in the temporary folder, elsewhere. A Reader and a Writer, blocking or Async, as TCP's are.
std/net/ipc.fb
Types
IpcStream
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.
-
@PanicsAtCaller Public Static Method Connect(name: String, timeout: Duration? = Null): IpcStream Throws NetError, TimeoutErrorstatic method #Connects to the IpcListener of
name, waiting up totimeout, 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, TimeoutErrorstatic method #Connect's Async twin, which waits on the main thread.
-
The name of the listener it's connected to, or that it came to.
-
How long a Read or ReadAsync waits for bytes before it throws, or Null, as it starts, to wait as long as it takes.
-
Whether Close closed it.
-
Reads what's come, at least a byte, waiting for some, or 0 once the other side ended what it writes.
-
Read's Async twin, which waits on the main thread instead of blocking it. One that can only block reads with Read.
Doc from
std.io.streams.Reader.ReadAsync. -
Writes all of from's bytes, returning once the OS has them.
-
Write's Async twin, which waits on the main thread instead of blocking it.
Doc from
std.io.streams.Writer.WriteAsync. -
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.
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.
-
@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 "Game" and "game" 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.