Skip to content

Instantly share code, notes, and snippets.

View claytonbez's full-sized avatar

Clayton Bezuidenhout claytonbez

  • Bestseller BV
  • The Netherlands
View GitHub Profile
@ndelangen
ndelangen / cluster-ipc.js
Created January 2, 2017 16:18
A NodeJS cluster communicating via ipc.
const cluster = require('cluster');
const http = require('http');
if (cluster.isMaster) {
// init cluster
require('os').cpus().forEach(() => {
cluster.fork();
});
// add eventlisteners
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');