Skip to content

Instantly share code, notes, and snippets.

View bhaveshgohel's full-sized avatar
👨‍💻
I may be slow to respond.

Bhavesh Gohel bhaveshgohel

👨‍💻
I may be slow to respond.
View GitHub Profile
@bhaveshgohel
bhaveshgohel / server.js
Created March 10, 2018 12:02 — forked from sadick254/server.js
A Simple TCP Chat Server In Node Js
//run this with 'node server.js' and then test in multiple computers using 'telnet 192.168.0.1 9000'
// replace '192.168.0.1' with your ip.
(function () {
'use strict';
let net = require('net');
let chatServer = net.createServer(),
clientList = []; // a list of connected clients/ machines
chatServer.on('connection', function (client) {
//once a client connects we add it to our clientList
// From callbacks to Promises to async functions
function callbackFunc(x, callback) {
f1(x, (err1, result1) => {
if (err1) {
console.error(err1);
callback(err1);
return;
}
f2(result1, (err2, result2) => {