dns.lookupService()

dns.lookupService(address, port, callback)

Resolves the given address and port into a hostname and service using the operating system's underlying getnameinfo implementation.

The callback has arguments (err, hostname, service). The hostname and service arguments are strings (e.g. 'localhost' and 'http' respectively).

On error, err is an Error object, where err.code is the error code.

const dns = require('dns');
dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
  console.log(hostname, service);
    // Prints: localhost ssh
});
doc_Nodejs
2016-04-30 04:38:54
Comments
Leave a Comment

Please login to continue.