Skip to content

Instantly share code, notes, and snippets.

@martinheidegger
Created Nov 7, 2015
Embed
What would you like to do?
Attempts for connecting to tcp server
var that = this
var makeAttempt = function () {
if (ports.length > 0) {
net.createConnection({port: ports[0]}, function () {
// test all ports
ports.shift()
makeAttempt()
}).on("error", function (e) {
attempt ++
if (attempt < 100) {
setTimeout(makeAttempt, 200)
} else {
exercise.emit('fail', 'Timeout occured')
}
})
} else {
query.call(that, mode)
return
}
}
makeAttempt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment