Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-ipc

Package Overview
Dependencies
Maintainers
12
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ipc

A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.

  • 12.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
526K
decreased by-0.92%
Maintainers
12
Weekly downloads
 
Created

What is node-ipc?

The node-ipc package is a Node.js module that provides a simple and flexible way to handle inter-process communication (IPC) in Node.js applications. It supports various types of communication, including local sockets, TCP, and UDP, making it suitable for a wide range of use cases such as microservices, distributed systems, and real-time applications.

What are node-ipc's main functionalities?

Local Socket Communication

This feature allows for communication between processes on the same machine using local sockets. The code sample demonstrates setting up a server that listens for messages and a client that sends and receives messages.

const ipc = require('node-ipc');

ipc.config.id = 'world';
ipc.config.retry = 1500;
ipc.config.silent = true;

ipc.serve(() => {
  ipc.server.on('message', (data, socket) => {
    ipc.log('Received message: ', data);
    ipc.server.emit(socket, 'message', 'Hello from server!');
  });
});

ipc.server.start();

// Client
ipc.connectTo('world', () => {
  ipc.of.world.on('connect', () => {
    ipc.log('Connected to world');
    ipc.of.world.emit('message', 'Hello from client!');
  });

  ipc.of.world.on('message', (data) => {
    ipc.log('Received message: ', data);
  });
});

TCP Communication

This feature enables communication over TCP, allowing processes to communicate over a network. The code sample shows how to set up a TCP server and a client that can send and receive messages.

const ipc = require('node-ipc');

ipc.config.id = 'tcpServer';
ipc.config.retry = 1500;
ipc.config.networkPort = 8000;
ipc.config.silent = true;

ipc.serveNet(() => {
  ipc.server.on('message', (data, socket) => {
    ipc.log('Received message: ', data);
    ipc.server.emit(socket, 'message', 'Hello from TCP server!');
  });
});

ipc.server.start();

// Client
ipc.connectToNet('tcpServer', 8000, () => {
  ipc.of.tcpServer.on('connect', () => {
    ipc.log('Connected to TCP server');
    ipc.of.tcpServer.emit('message', 'Hello from TCP client!');
  });

  ipc.of.tcpServer.on('message', (data) => {
    ipc.log('Received message: ', data);
  });
});

UDP Communication

This feature supports communication over UDP, which is useful for applications that require low-latency communication. The code sample demonstrates setting up a UDP server and a client that can send and receive messages.

const ipc = require('node-ipc');

ipc.config.id = 'udpServer';
ipc.config.retry = 1500;
ipc.config.networkPort = 8001;
ipc.config.silent = true;

ipc.serveUDP(() => {
  ipc.server.on('message', (data, socket) => {
    ipc.log('Received message: ', data);
    ipc.server.emit(socket, 'message', 'Hello from UDP server!');
  });
});

ipc.server.start();

// Client
ipc.connectToUDP('udpServer', 8001, () => {
  ipc.of.udpServer.on('connect', () => {
    ipc.log('Connected to UDP server');
    ipc.of.udpServer.emit('message', 'Hello from UDP client!');
  });

  ipc.of.udpServer.on('message', (data) => {
    ipc.log('Received message: ', data);
  });
});

Other packages similar to node-ipc

Keywords

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc