Ordered stream
TCP preserves byte order and retransmits lost packets. node-ipc frames application events inside that stream.
Reliable network transport
Use TCP when messages must arrive in order across a network and the application can tolerate connection setup and retransmission.
TCP preserves byte order and retransmits lost packets. node-ipc frames application events inside that stream.
The server tracks connected sockets and can reply to one or broadcast to all.
Clients use retry, maxRetries, and stopRetrying after a close.
import ipc from 'node-ipc';
ipc.config.id = 'events';
ipc.config.networkHost = '127.0.0.1';
ipc.config.networkPort = 8000;
ipc.serveNet(() => {
ipc.server.on('ping', (data, socket) => {
ipc.server.emit(socket, 'pong', {received: data});
});
});
ipc.server.start();Passing no arguments uses networkHost and networkPort. Register handlers before start().
ipc.connectToNet('events', '127.0.0.1', 8000, () => {
ipc.of.events.on('connect', () => {
ipc.of.events.emit('ping', {at: Date.now()});
});
ipc.of.events.on('pong', data => console.log(data));
ipc.of.events.on('error', error => console.error(error));
});Use the same id when reading the client from ipc.of. The id does not authenticate the remote server.
| Host | Reach | Use |
|---|---|---|
127.0.0.1 / ::1 | Local machine | Default and preferred when remote access is unnecessary. |
| Private interface | Routable private network | Require application authorization and network controls. |
0.0.0.0 / :: | Every interface | Only after an explicit threat review; plain TCP is not confidential or authenticated. |
It provides neither encryption nor peer authentication. Use TLS plus an identity policy, or authenticate and authorize every application message.
maxConnections, application rate limits, and retry behavior against expected traffic.error, disconnect, and duplicate work after reconnect.