Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
A nodejs module for local and remote Inter Process Communication (IPC) uses Unix Sockets for local communication avoiding the network card for lower overhead and latency. ## Solid but, ### Still under development and lacking documentation, but useable.
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.
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);
});
});
Socket.IO is a popular library for real-time web applications. It enables real-time, bidirectional communication between web clients and servers. Unlike node-ipc, which focuses on inter-process communication, Socket.IO is designed for web applications and provides features like automatic reconnection, multiplexing, and broadcasting.
Dnode is a library for asynchronous, bidirectional RPC (Remote Procedure Call) in Node.js. It allows you to call functions in another process or even on another machine as if they were local. Dnode is more focused on RPC, whereas node-ipc provides a broader range of IPC mechanisms.
ZeroMQ (also known as ØMQ) is a high-performance asynchronous messaging library. It provides a message queue but unlike traditional message brokers, it can be used for various messaging patterns like pub-sub, request-reply, and push-pull. ZeroMQ is more complex and powerful compared to node-ipc, which is simpler and easier to use for basic IPC needs.
#node-ipc a nodejs module for local and remote Inter Process Communication
npm install node-ipc
this is a new project so more documentation will come
Uses Unix Sockets to give lightning fast communication and avoid the network card to reduce overhead and latency.
The server is the process keeping a Unix Socket for IPC open. Multiple sockets can connect to this server and talk to it. It can also broadcast to all clients or emit to a specific client.
var ipc=require('node-ipc');
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.serve(
function(){
ipc.server.on(
'message',
function(data,socket){
ipc.log('got a message : '.debug, data);
socket.emit(
'message',
data+' world!'
);
}
);
}
);
ipc.server.start();
The client connects to the servers Unix Socket for Inter Process Communication. The socket will recieve events emitted to it specifically as well as events which are broadcast out on the Unix Socket by the server.
var ipc=require('../../../node-ipc');
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.connectTo(
'world',
function(){
ipc.of.world.on(
'connect',
function(){
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
ipc.of.world.emit(
'message',
'hello'
)
}
);
ipc.of.world.on(
'disconnect',
function(){
ipc.log('disconnected from world'.notice);
}
);
ipc.of.world.on(
'message',
function(data){
ipc.log('got a message from world : '.debug, data);
}
);
}
);
Uses not yet defined
Sockets to give fastest possible communication across the network with the minimum overhead and latency.
FAQs
A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.
The npm package node-ipc receives a total of 534,974 weekly downloads. As such, node-ipc popularity was classified as popular.
We found that node-ipc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.