This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) => { |
OlderNewer