Simplify the DNS usage example.

v0.7.4-release
Ryan 2009-07-30 15:54:38 +02:00
parent 41d89f611f
commit 4db8bb9375
1 changed files with 21 additions and 25 deletions

View File

@ -1010,16 +1010,13 @@ necessary in case of errors (parse error or so).
=== DNS
Here is an example of which reads domains from the command line, resolves
them, then reverse resolves the IP addresses returned.
Here is an example of which resolves +"www.google.com"+ then reverse
resolves the IP addresses which are returned.
-------------------------------------------------------------------------
for (var i = 2; i < ARGV.length; i++) {
var name = ARGV[i]
puts("looking up " + name);
var resolution = node.dns.resolve4(name);
var resolution = node.dns.resolve4("www.google.com");
resolution.addCallback(function (addresses, ttl, cname) {
resolution.addCallback(function (addresses, ttl, cname) {
puts("addresses: " + JSON.stringify(addresses));
puts("ttl: " + JSON.stringify(ttl));
puts("cname: " + JSON.stringify(cname));
@ -1034,12 +1031,11 @@ for (var i = 2; i < ARGV.length; i++) {
puts("reverse for " + a + " failed: " + msg);
});
}
});
});
resolution.addErrback(function (code, msg) {
resolution.addErrback(function (code, msg) {
puts("error: " + msg);
});
}
});
-------------------------------------------------------------------------