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

@achrinza/node-ipc

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@achrinza/node-ipc

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

  • 10.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
468K
decreased by-13.37%
Maintainers
1
Weekly downloads
 
Created

What is @achrinza/node-ipc?

@achrinza/node-ipc is a Node.js package that facilitates inter-process communication (IPC) between Node.js processes. It supports various communication methods, including Unix sockets, TCP, and UDP, making it versatile for different IPC needs.

What are @achrinza/node-ipc's main functionalities?

Unix Socket Communication

This feature allows for communication between processes using Unix sockets. The server listens for messages and responds, while the client sends a message and listens for a response.

const ipc = require('@achrinza/node-ipc');

ipc.config.id = 'hello';
ipc.config.retry = 1500;

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

ipc.server.start();

// Client
ipc.connectTo('hello', () => {
  ipc.of.hello.on('connect', () => {
    ipc.of.hello.emit('message', 'Hello from client');
  });

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

TCP Communication

This feature enables communication over TCP. The server listens on a specified port and handles messages, while the client connects to the server and exchanges messages.

const ipc = require('@achrinza/node-ipc');

ipc.config.id = 'world';
ipc.config.retry = 1500;
ipc.config.networkPort = 8000;

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

ipc.server.start();

// Client
ipc.connectToNet('world', 8000, () => {
  ipc.of.world.on('connect', () => {
    ipc.of.world.emit('message', 'Hello from TCP client');
  });

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

UDP Communication

This feature allows for communication over UDP. The server listens on a specified port and handles messages, while the client connects to the server and exchanges messages.

const ipc = require('@achrinza/node-ipc');

ipc.config.id = 'udp';
ipc.config.retry = 1500;
ipc.config.networkPort = 8001;
ipc.config.networkHost = 'localhost';

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

ipc.server.start();

// Client
ipc.connectToUDP('udp', 8001, 'localhost', () => {
  ipc.of.udp.on('connect', () => {
    ipc.of.udp.emit('message', 'Hello from UDP client');
  });

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

Other packages similar to @achrinza/node-ipc

Keywords

FAQs

Package last updated on 22 Jun 2023

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