IpcServer
Defined in: packages/node/src/net/ipc-server.ts:45
Server accepting connections on a Unix domain socket or a Windows named pipe.
Example usage:
const server = IpcServer.from();server.subscribe("connection", (socket) => { socket.stream.on("data", (data) => { console.log("Received:", data.toString()); });});await server.listen("/var/run/app.sock");// ... laterawait server.close();On Unix the socket file is removed when the server closes, but not when the
process exits abnormally: a stale file makes the next bind fail with
EADDRINUSE.
Extends
Section titled “Extends”StreamServer<net.Server,IpcServerEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IpcServer(
server):IpcServer
Defined in: packages/node/src/net/stream-server.ts:43
Creates a new StreamServer instance.
Parameters
Section titled “Parameters”server
Section titled “server”Server
The underlying Node.js server.
Returns
Section titled “Returns”IpcServer
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”listening
Section titled “listening”Get Signature
Section titled “Get Signature”get listening():
boolean
Defined in: packages/node/src/net/stream-server.ts:49
Whether the server is currently listening for connections.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”maxConnections
Section titled “maxConnections”Get Signature
Section titled “Get Signature”get maxConnections():
number
Defined in: packages/node/src/net/stream-server.ts:54
Maximum number of concurrent connections accepted by the server.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set maxConnections(
maxConnections):void
Defined in: packages/node/src/net/stream-server.ts:63
Updates the maximum number of concurrent connections.
Connections accepted beyond this limit are dropped.
Parameters
Section titled “Parameters”maxConnections
Section titled “maxConnections”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”address()
Section titled “address()”address():
string|null
Defined in: packages/node/src/net/ipc-server.ts:79
Returns the path the server is bound to.
Returns
Section titled “Returns”string | null
The bound path, or null when the server is not listening.
Throws
Section titled “Throws”When the server is bound to an IP endpoint rather than a path. Use TcpServer for those.
close()
Section titled “close()”close():
Promise<void>
Defined in: packages/node/src/net/stream-server.ts:107
Stops the server from accepting new connections. Established connections are not closed; the promise resolves once the last of them ends.
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the server is fully closed.
Throws
Section titled “Throws”When the server was not listening.
Inherited from
Section titled “Inherited from”getConnections()
Section titled “getConnections()”getConnections():
Promise<number>
Defined in: packages/node/src/net/stream-server.ts:72
Counts the connections currently handled by the server.
Returns
Section titled “Returns”Promise<number>
A promise that resolves with the connection count.
Inherited from
Section titled “Inherited from”isSubscribed()
Section titled “isSubscribed()”isSubscribed<
K>(event,listener):boolean
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38
Check if a callback is subscribed to a specific event.
Type Parameters
Section titled “Type Parameters”K extends "connection" | keyof StreamServerEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<IpcServerEvents[K]>
The callback to check.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”listen()
Section titled “listen()”listen(
path,options?):Promise<void>
Defined in: packages/node/src/net/ipc-server.ts:65
Binds the server to the given path and resolves once it is listening.
Parameters
Section titled “Parameters”string
Filesystem path of the Unix domain socket, or the name of the Windows named pipe.
options?
Section titled “options?”Additional listen options.
backlog?
Section titled “backlog?”number
exclusive?
Section titled “exclusive?”boolean
readableAll?
Section titled “readableAll?”boolean
signal?
Section titled “signal?”AbortSignal
writableAll?
Section titled “writableAll?”boolean
Returns
Section titled “Returns”Promise<void>
A promise that resolves once the server is listening.
Throws
Section titled “Throws”When the path is already in use or cannot be bound.
ref():
void
Defined in: packages/node/src/net/stream-server.ts:88
Marks the server as referenced, preventing the Node.js process from exiting while it is listening.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”subscribe()
Section titled “subscribe()”subscribe<
K>(event,listener,options?):Callable|null
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23
Type Parameters
Section titled “Type Parameters”K extends "connection" | keyof StreamServerEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<IpcServerEvents[K]>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Returns
Section titled “Returns”Callable | null
Inherited from
Section titled “Inherited from”unref()
Section titled “unref()”unref():
void
Defined in: packages/node/src/net/stream-server.ts:96
Marks the server as unreferenced, allowing the Node.js process to exit even while it is listening.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”unsubscribe()
Section titled “unsubscribe()”unsubscribe<
K>(event,listener):void
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31
Unsubscribe a callback from a specific event.
Type Parameters
Section titled “Type Parameters”K extends "connection" | keyof StreamServerEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<IpcServerEvents[K]>
The callback to remove.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”wait()
Section titled “wait()”wait<
K>(event,options?):Promise<IpcServerEvents[K]>
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:45
Wait for the next occurrence of a specific event, optionally matching a predicate.
This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.
Type Parameters
Section titled “Type Parameters”K extends "connection" | keyof StreamServerEvents
Parameters
Section titled “Parameters”K
The event name to wait for.
options?
Section titled “options?”EventDispatcherWaitOptions<IpcServerEvents[K]>
Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<IpcServerEvents[K]>
A promise that resolves with the event arguments as an array.
Inherited from
Section titled “Inherited from”from()
Section titled “from()”
staticfrom(options?):IpcServer
Defined in: packages/node/src/net/ipc-server.ts:52
Creates a new IpcServer instance.
Parameters
Section titled “Parameters”options?
Section titled “options?”ServerOpts
Options for creating the underlying Node.js server.
Returns
Section titled “Returns”IpcServer
A new IpcServer instance.