Created
May 22, 2013 14:30
-
-
Save robertklep/5627971 to your computer and use it in GitHub Desktop.
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'); | |
var inbound = net.createServer(); | |
var outbound = null; | |
setTimeout(function() { | |
console.log('starting to listen on :8192'); | |
inbound.listen(8192, function () { | |
address = inbound.address(); | |
console.log('Server started on %j', address); | |
}); | |
inbound.on('connection', function(insock) { | |
console.log('inbound got a connection!'); | |
}); | |
}, 2000); | |
var interval = setInterval(function() { | |
console.log('lets check if port 8192 is open...'); | |
outbound = net.connect({ port: 8192 }); | |
outbound.on('error', function(err) { | |
console.log('...received an error', err.code); | |
}); | |
outbound.on('connect', function() { | |
console.log('...outbound got a connection!'); | |
clearInterval(interval); | |
}); | |
}, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment