net-ipc
Advanced tools
Weekly downloads
Readme
A simple message based IPC client/server providing bi-directional communication over sockets and TCP.
fast-zlib
)msgpackr
)Local IPC server for communication between processes in the same machine.
const { Server } = require("net-ipc");
const server = new Server({
path: "/myapp"
});
server.start().catch(console.error);
TCP server for remote communication over the internet.
const { Server } = require("net-ipc");
const server = new Server({
port: 4466
});
server.start().catch(console.error);
Secure TCP server with a domain name and an SSL certificate directly exposed to the web.
const { readFileSync } = require("fs");
const { Server } = require("net-ipc");
const server = new Server({
port: 443,
tls: true,
options: {
cert: readFileSync("/path/to/certificate.pem"),
key: readFileSync("/path/to/key.pem")
}
});
server.start().catch(console.error);
Secure TCP server using PSK (pre shared key) instead of an SSL certificate and a domain name. This setup enables secure connections between direct IP addresses.
const USER = "some username";
const KEY = Buffer.from("some password");
const { Server } = require("net-ipc");
const server = new Server({
port: 4466,
tls: true,
options: {
pskCallback: (socket, identity) => {
if(identity === USER) { // confirm username
return KEY; // return password for verification
}
},
ciphers: "PSK", // enable PSK ciphers, they are disabled by default
}
});
server.start().catch(console.error);
Connecting to a local IPC server.
const { Client } = require("net-ipc");
const client = new Client({
path: "/myapp";
});
client.connect().catch(console.error);
Connecting to a remote TCP server.
const { Client } = require("net-ipc");
const client = new Client({
host: "192.168.1.25",
port: 4466
});
client.connect().catch(console.error);
Connecting to a remote TCP server secured with an SSL certificate and a domain name.
const { Client } = require("net-ipc");
const client = new Client({
host: "somedomain.com",
port: 443,
tls: true
});
client.connect().catch(console.error);
Connecting to a remote TCP server secured with a PSK.
const USER = "username here";
const KEY = "password here";
const { Client } = require("net-ipc");
const client = new Client({
host: "192.168.1.35",
port: 4466,
tls: true,
options: {
pskCallback: () => {
// return the user and the key for verification
return {
identity: USER,
psk: Buffer.from(KEY)
}
},
ciphers: "PSK", // enable PSK ciphers, they are disabled by default
checkServerIdentity: () => void 0; // bypass SSL certificate verification since we are not using certificates
}
});
client.connect().catch(console.error);
Connecting to a TCP server behind an SSL proxy (nginx/replit/etc). The server itself does not need to be secure as the proxy does it instead.
const { Client } = require("net-ipc");
const client = new Client({
host: "somedomain.com",
port: 443,
tls: true,
handshake: true // simulates websocket http handshake
});
client.connect().catch(console.error);
Request and response example:
// server side
server.on("request", async (req, res, client) => {
if(req.type === "fetch") {
const fetched = await someDatabase.fetch(req.data);
await res(fetched);
}
});
// client side
const fetched = await client.request({ type: "fetch", data: "someID" });
FAQs
Simple message based IPC client/server providing bi-directional communication over sockets and TCP. Supports one-way messages, promise-based request-response, survey, broadcast and zlib-stream compression
The npm package net-ipc receives a total of 631 weekly downloads. As such, net-ipc popularity was classified as not popular.
We found that net-ipc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.