Node.js – dns.resolveNs() 方法
dns.resolveNs() 方法利用 DNS 協議解決主機名的名稱伺服器記錄(NS 記錄)。傳遞給回撥函式的地址引數將包含主機名的名稱伺服器記錄陣列。
語法
dns.resolveNs(hostname, callback)
引數
定義以上引數如下 -
hostname – 此引數輸入主機名的解析所用值。
callback – 此函式將捕獲錯誤(如有)。
records – 為主機名返回名稱伺服器(NS)記錄。
示例 1
建立一個檔案 "resolveNs.js" 並複製以下程式碼段。建立檔案後,使用命令 "node resolveNs.js" 執行該程式碼
// dns.resolveNs() Demo Example
// Importing the dns module
const dns = require('dns');
// Passing the argument below
dns.resolveNs('tutorialspoint.com', (err,records) => console.log('NS Records: %j', records));輸出
NS Records: undefined
示例 2
// dns.resolveNs() Demo Example
// Importing the dns module
const dns = require('dns');
// Passing the argument below
dns.resolveNs('google.com', (err,records) => console.log('NS Records: %j', records));輸出
NS Records: undefined
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP