Xbase++
Xbase++
DNS Query NS Records
See more DNS Examples
Shows how to perform a DNS query to retrieve NS records.Note: This example requires Chilkat v9.5.0.96 or later.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oDns
LOCAL oJson
LOCAL cName
LOCAL nTtl
LOCAL cDomain
LOCAL i
LOCAL nCount_i
nSuccess := 0
oDns := CreateObject("Chilkat.Dns")
oJson := CreateObject("Chilkat.JsonObject")
oJson:EmitCompact := 0
nSuccess := oDns:Query("NS", "x.com", oJson)
IF (nSuccess == 0)
? oDns:LastErrorText
oDns:destroy()
oJson:destroy()
RETURN
ENDIF
? oJson:Emit()
// Sample response.
// Parsing code below..
// {
// "answer": {
// "ns": [
// {
// "name": "x.com",
// "ttl": 86400,
// "domain": "alexia.ns.cloudflare.com"
// },
// {
// "name": "x.com",
// "ttl": 86400,
// "domain": "tosana.ns.cloudflare.com"
// }
// ]
// }
// }
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
i := 0
nCount_i := oJson:SizeOfArray("answer.ns")
DO WHILE i < nCount_i
oJson:I := i
cName := oJson:StringOf("answer.ns[i].name")
nTtl := oJson:IntOf("answer.ns[i].ttl")
cDomain := oJson:StringOf("answer.ns[i].domain")
i := i + 1
ENDDO
oDns:destroy()
oJson:destroy()