What is the use of DNS module in Node.js?
dns module which provide underlying system's name resolution and DNS look up facilities. DNS module consists of an asynchronous network wrapper.
The most commonly used functions in DNS module are:
dns.lookup(adress, options, callback)- The dns lookup method takes any website address as its first parameter and returns the corresponding first IPV4 or IPV6 record. The options parameter can be an integer or object. If no options are provided both IPV4 and IPV6 are valid inputs. The third parameter is the callback functions.dns.lookupservice(address, port, callback)- This function converts any physical address such as “www.knowledgehills.com” to array of record types. The record types are specified by the second parameter “rrbyte”. Finally the third method is the callback function.dns.getServers()- This function returns an array of IP address strings, formatted according to rfc5952, that are currently configured for DNS resolution. A string will include a port section if a custom port is used.dns.setServers()- This function sets the IP address and port of servers to be used when performing DNS resolution. Thedns.setServers()method must not be called while a DNS query is in progress.
Comments
Post a Comment