If I execute a number of asynchronous http requests in a for loop, is the order that those sockets are added to the event loop deterministic/guaranteed to be in the order that the loop executed?
function makeRequest(n) {
http.get("http://www.google.com/index.html?=" + n, function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
}
for (var i=0; i<10; i++) {
makeRequest(i);
}
I was talking with a coworker and we were trying to figure out if this could be true. Because node event loop, libuv, and socket/OS programming is new to me, it was all speculation.
There's not really a practical programming application to this just trying to develop and understanding.
Thank you