Reliable network transport

TCP

Use TCP when messages must arrive in order across a network and the application can tolerate connection setup and retransmission.

Connection shape

Ordered stream

TCP preserves byte order and retransmits lost packets. node-ipc frames application events inside that stream.

One server, many clients

The server tracks connected sockets and can reply to one or broadcast to all.

Reconnect policy

Clients use retry, maxRetries, and stopRetrying after a close.

TCP server

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().

TCP client

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.

Bind deliberately

HostReachUse
127.0.0.1 / ::1Local machineDefault and preferred when remote access is unnecessary.
Private interfaceRoutable private networkRequire application authorization and network controls.
0.0.0.0 / ::Every interfaceOnly after an explicit threat review; plain TCP is not confidential or authenticated.
TCP is transport reliability, not identity.

It provides neither encryption nor peer authentication. Use TLS plus an identity policy, or authenticate and authorize every application message.

Operational checklist

  • Keep loopback until remote reachability is a requirement.
  • Select Guarded or Assured before endpoint construction when frame, timeout, name, or pending-write controls are required.
  • Budget maxConnections, application rate limits, and retry behavior against expected traffic.
  • Handle error, disconnect, and duplicate work after reconnect.
  • Authenticate peers and authorize commands; TCP provides neither identity nor confidentiality.