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 });
Please login to continue.