No network hop
Traffic stays on the machine and avoids TCP or UDP routing.
Same-machine transport
Use serve and connectTo when both processes share a machine. node-ipc maps the logical path to the native local transport.
Traffic stays on the machine and avoids TCP or UDP routing.
The default path combines socketRoot, appspace, and service id.
Unix uses a filesystem socket path; Windows converts that logical path to \\.\pipe\….
import ipc from 'node-ipc';
ipc.config.id = 'inventory';
ipc.serve(() => {
ipc.server.on('lookup', (sku, socket) => {
ipc.server.emit(socket, 'lookup.result', {sku, available: true});
});
});
ipc.server.start();Omit the path to use socketRoot + appspace + id, or pass an explicit logical path as the first argument.
ipc.connectTo('inventory', () => {
ipc.of.inventory.on('connect', () => {
ipc.of.inventory.emit('lookup', 'SKU-42');
});
ipc.of.inventory.on('lookup.result', result => {
console.log(result);
ipc.disconnect('inventory');
});
});The client is immediately available at ipc.of.inventory; wait for connect before emitting.
| Platform | Default shape | Operational concern |
|---|---|---|
| Linux / macOS | Derived runtime directory + app.inventory | Verify the actual directory owner and mode; they define who can reach the socket. |
| Windows | \\.\pipe\node-ipc-user-app.inventory | readableAll and writableAll request broader access; leave them false unless required. |
Local socket permissions do not authenticate messages. Verify the actual directory owner, mode, endpoint location, and host-user boundary in the environment where the service runs.
unlink: true for one owner of one socket path.unlink: false only when a clustered design owns deletion explicitly.ipc.disconnect(id) for clients and ipc.server.stop() for servers during orderly shutdown.