Created
April 18, 2016 07:46
-
-
Save eplawless/ac41bc976f2982ecfe0f4253883339aa to your computer and use it in GitHub Desktop.
This had better not work...
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
var net = require('net'); | |
function startServer(port, host, callback) { | |
var server = net.createServer(); | |
server.listen(port, host, function() { | |
callback(undefined, server); | |
}); | |
server.on('error', function(error) { | |
console.error('Ah damn!', error); | |
callback(error); | |
}); | |
} | |
startServer(4000, '0.0.0.0', function(error, wildcardServer) { | |
if (error) return; | |
startServer(4000, '127.0.0.1', function(error, localhostServer) { | |
if (error) return; | |
console.log('Started both servers!'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run this exact code on my computer, I get this error:
I cannot make them to run and print "Started both servers!"