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.




import nativesockets
 
iterator items(ai: ptr AddrInfo): ptr AddrInfo =
  var current = ai
  while current != nil:
    yield current
    current = current.aiNext
 
proc main() =
  let addrInfos = getAddrInfo("www.kame.net", Port 80, AfUnspec)
  defer: freeAddrInfo addrInfos
 
  for i in addrInfos:
    echo getAddrString i.aiAddr
 
when isMainModule: main()