How to resolve the algorithm DNS query step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm DNS query step by step in the Wren programming language
Table of Contents
Problem Statement
DNS is an internet service that maps domain names, like rosettacode.org, to IP addresses, like 66.220.0.231. Use DNS to resolve www.kame.net to both IPv4 and IPv6 addresses. Print these addresses.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm DNS query step by step in the Wren programming language
Source code in the wren programming language
/* DNS_query.wren */
class Net {
foreign static lookupHost(host)
}
var host = "orange.kame.net"
var addrs = Net.lookupHost(host).split(", ")
System.print(addrs.join("\n"))
/* go run DNS_query.go */
package main
import(
wren "github.com/crazyinfin8/WrenGo"
"net"
"strings"
)
type any = interface{}
func lookupHost(vm *wren.VM, parameters []any) (any, error) {
host := parameters[1].(string)
addrs, err := net.LookupHost(host)
if err != nil {
return nil, nil
}
return strings.Join(addrs, ", "), nil
}
func main() {
vm := wren.NewVM()
fileName := "DNS_query.wren"
methodMap := wren.MethodMap{"static lookupHost(_)": lookupHost}
classMap := wren.ClassMap{"Net": wren.NewClass(nil, nil, methodMap)}
module := wren.NewModule(classMap)
vm.SetModule(fileName, module)
vm.InterpretFile(fileName)
vm.Free()
}
You may also check:How to resolve the algorithm Least common multiple step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Hash from two arrays step by step in the jq programming language
You may also check:How to resolve the algorithm Variable size/Get step by step in the Ada programming language
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the ERRE programming language
You may also check:How to resolve the algorithm Function definition step by step in the AArch64 Assembly programming language