-
-
Save martinheidegger/a7cf754d91f847c29965 to your computer and use it in GitHub Desktop.
Attempts for connecting to tcp server
This file contains 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 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