I need to find this node in the corresponding IP address in Node.js. There seem to be two own methods:
> dns.resolve('google.com', (error, addresses) => { console.error(error); console.log(addresses); }); QueryReqWrap { bindingName: 'queryA', callback: { [Function: asyncCallback] immediately: true }, hostname: 'google.com', oncomplete: [Function: onresolve], domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } > null [ '216.58.194.174' ]
and
> dns.lookup('google.com', (error, address, family) => { console.error(error); console.log(address); console.log(family); }); GetAddrInfoReqWrap { callback: { [Function: asyncCallback] immediately: true }, family: 0, hostname: 'google.com', oncomplete: [Function: onlookup], domain: Domain { domain: null, _events: { error: [Function] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } > null 216.58.194.174 4
Both return the same IPv4 address. What is the difference between dns.lookup() and dns.resolve() ? Also, which is more efficient for multiple queries per second?
source share