New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ipc-link-core

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipc-link-core

IPC Utilities

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

IPC-Link Core is a lower level version of IPC-Link that is lightning fast and operates with raw buffers as opposed to sending buffered stringified JSON objects. This library has no dependencies and uses built-in modules (net, events...) to operate.

In IPC-Link Core, you have "nodes", which can either create a server (and receive messages) or connect to other servers, even both at the same time. Additionally, you have Node#sendTo(socket, data); which will wait for the socket to reply back.

Usage

Check the examples here for working micro IPC-Link Core applications.

hello.js

// This example must be run before interactive/world, since this serves the
// IPC server the other sockets connect to.
const { Node } = require('ipc-link-core');

const node = new Node('hello')
	.on('connection', (name, socket) => {
		console.log(`Connected to ${name}`);
		node.sendTo(socket, 'Hello')
			.then(reply => console.log(`Hello ${reply}`));
	})
	.on('listening', console.log.bind(null, 'Listening'))
	.on('message', console.log.bind(null, 'Message'))
	.on('error', console.error.bind(null, 'Error'))
	.on('socketClose', console.log.bind(null, 'Closed Socket:'))
	.serve('hello', 8001);

world.js

// This example depends on hello.js to be running in another process.
// This Node is a socket that replies to hello.js with "world!" when it
// receives "Hello".
const { Node } = require('ipc-link-core');

const node = new Node('world')
	.on('message', (message) => {
		console.log(`Received data from ${message.from}:`, message);
		if (message.data === 'Hello')
			message.reply('world!');
	})
	.on('error', console.error)
	.on('connect', () => console.log('Connected!'));

node.connectTo('hello', 8001)
	.catch(() => console.log('Disconnected!'));

The differences with IPC-Link are:

  • IPC-Link Core does not rely on node-ipc, but rather uses net.Socket, net.Server and events.EventEmitter.
  • IPC-Link Core does not use JSON objects: it uses buffers with headers.
  • IPC-Link Core does not abstract net.Socket#connect nor net.Server#listen, as opposed to what node-ipc does.
  • IPC-Link Core does not send a message to a socket if it's not connected, you must connect first (in node-ipc, it attempts to connect using the name, which breaks in many cases and leads to unexpected behaviour).

Keywords

FAQs

Package last updated on 02 Jul 2018

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