Skip to content

Instantly share code, notes, and snippets.

@shardulmohite
Last active August 29, 2015 13:56
Show Gist options
  • Save shardulmohite/f2956009a53d573f1e14 to your computer and use it in GitHub Desktop.
Save shardulmohite/f2956009a53d573f1e14 to your computer and use it in GitHub Desktop.
DNS look up , example of Non-Blocking function of JS .
var SiteArray = ['google.com','webonise.com','facebook.com','techcrunch.com','indiatimes.com'];
var dns = require('dns');
for(var i = 0 ; i < SiteArray.length ; i++){
dns.lookup(SiteArray[i],function(err,ip){
if (err) return handleError(err);
console.log( " %s resolved to %s ", SiteArray[i],ip );
});
}
@vishaltelangre
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment