Skip to content

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");
// ... later
await 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.

new IpcServer(server): IpcServer

Defined in: packages/node/src/net/stream-server.ts:43

Creates a new StreamServer instance.

Server

The underlying Node.js server.

IpcServer

StreamServer.constructor

get listening(): boolean

Defined in: packages/node/src/net/stream-server.ts:49

Whether the server is currently listening for connections.

boolean

StreamServer.listening


get maxConnections(): number

Defined in: packages/node/src/net/stream-server.ts:54

Maximum number of concurrent connections accepted by the server.

number

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.

number

void

StreamServer.maxConnections

address(): string | null

Defined in: packages/node/src/net/ipc-server.ts:79

Returns the path the server is bound to.

string | null

The bound path, or null when the server is not listening.

When the server is bound to an IP endpoint rather than a path. Use TcpServer for those.


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.

Promise<void>

A promise that resolves when the server is fully closed.

When the server was not listening.

StreamServer.close


getConnections(): Promise<number>

Defined in: packages/node/src/net/stream-server.ts:72

Counts the connections currently handled by the server.

Promise<number>

A promise that resolves with the connection count.

StreamServer.getConnections


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.

K extends "connection" | keyof StreamServerEvents

K

The event name.

Callable<IpcServerEvents[K]>

The callback to check.

boolean

StreamServer.isSubscribed


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.

string

Filesystem path of the Unix domain socket, or the name of the Windows named pipe.

Additional listen options.

number

boolean

boolean

AbortSignal

boolean

Promise<void>

A promise that resolves once the server is listening.

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.

void

StreamServer.ref


subscribe<K>(event, listener, options?): Callable | null

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23

K extends "connection" | keyof StreamServerEvents

K

Callable<IpcServerEvents[K]>

EventDispatcherSubscribeOptions

Callable | null

StreamServer.subscribe


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.

void

StreamServer.unref


unsubscribe<K>(event, listener): void

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31

Unsubscribe a callback from a specific event.

K extends "connection" | keyof StreamServerEvents

K

The event name.

Callable<IpcServerEvents[K]>

The callback to remove.

void

StreamServer.unsubscribe


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.

K extends "connection" | keyof StreamServerEvents

K

The event name to wait for.

EventDispatcherWaitOptions<IpcServerEvents[K]>

Optional settings including predicate and abort signal.

Promise<IpcServerEvents[K]>

A promise that resolves with the event arguments as an array.

StreamServer.wait


static from(options?): IpcServer

Defined in: packages/node/src/net/ipc-server.ts:52

Creates a new IpcServer instance.

ServerOpts

Options for creating the underlying Node.js server.

IpcServer

A new IpcServer instance.