DNS query: Difference between revisions

m
syntax highlighting fixup automation
(Corrected headers)
m (syntax highlighting fixup automation)
Line 7:
=={{header|Ada}}==
{{works with|GNAT GPL|Any - package Gnat.Sockets supports only IPv4 as of Jun 2011}}
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;
 
Line 19:
Inet_Addr_V4 := Addresses (Host);
Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;</langsyntaxhighlight>
 
{{works with|GNAT GPL|2019 - support for IPv6 was added to Gnat.Sockets sometime before this}}
 
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use Gnat.Sockets;
procedure DNSQuerying is
Line 36:
begin
Print_Address_Info ("ipv6.google.com", "https", Family_Inet6);
end DNSQuerying;</langsyntaxhighlight>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang="arm assembly">
<lang ARM Assembly>
 
/* ARM assembly Raspberry PI */
Line 205:
pop {r0,r1,r2,r7,lr} @ restaur des 2 registres */
bx lr @ return
</syntaxhighlight>
</lang>
 
=={{header|AutoHotkey}}==
This code uses Windows built-in 'nslookup' command (and a temporary file):
<langsyntaxhighlight AutoHotkeylang="autohotkey">Url := "www.kame.net" , LogFile := "Ping_" A_Now ".log"
Runwait, %comspec% /c nslookup %Url%>%LogFile%, , hide
FileRead, Contents, %LogFile%
FileDelete, %LogFile%
RegExMatch(Contents,"Addresses:.+(`r?`n\s+.+)*",Match)
MsgBox, % RegExReplace(Match,"(Addresses:|[ `t])")</langsyntaxhighlight>
 
=={{header|Batch File}}==
<langsyntaxhighlight lang="dos">:: DNS Query Task from Rosetta Code Wiki
:: Batch File Implementation
 
Line 254:
)
endlocal
goto :EOF</langsyntaxhighlight>
{{Out}}
<pre>DOMAIN: "www.kame.net"
Line 264:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> name$ = "www.kame.net"
AF_INET = 2
Line 316:
SYS `WSACleanup`
</syntaxhighlight>
</lang>
Output:
<pre>IPv4 address = 203.178.141.194
Line 324:
This solution uses <code>getaddrinfo()</code>, a standard function from RFC 3493. This code resembles an example from [http://www.openbsd.org/cgi-bin/man.cgi?query=getaddrinfo&apropos=0&sektion=3&manpath=OpenBSD+Current&arch=i386&format=html getaddrinfo(3)], the [[BSD]] manual page. Whereas the man page code connects to <code>www.kame.net</code>, this code only prints the numeric addresses.
 
<langsyntaxhighlight lang="c">#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h> /* getaddrinfo, getnameinfo */
Line 381:
 
return 0;
}</langsyntaxhighlight>
 
=={{header|C sharp|C#}}==
Implementation takes a host name string as a parameter, and returns the IP addresses in a comma-delimited string. Note that a failed lookup throws a SocketException.
<langsyntaxhighlight lang="csharp">
private string LookupDns(string s)
{
Line 404:
}
}
</syntaxhighlight>
</lang>
 
=={{header|C++}}==
This example makes use of the Boost library. The asio bit is header-only, but requires linking boost-system (e.g. -lboost_system). The compiler may also need to be told to use C++11 semantics (e.g. -std=c++11).
<syntaxhighlight lang="c++">
<lang C++>
#include <boost/asio.hpp>
#include <iostream>
Line 429:
return rc;
}
</syntaxhighlight>
</lang>
 
=={{header|Caché ObjectScript}}==
 
<langsyntaxhighlight lang="cos">
Class Utils.Net Extends %RegisteredObject
{
Line 482:
 
}
</syntaxhighlight>
</lang>
 
<langsyntaxhighlight lang="cos">
Class Utils.OS Extends %RegisteredObject
{
Line 519:
 
}
</syntaxhighlight>
</lang>
{{out|Examples}}
<pre>
Line 536:
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(import java.net.InetAddress java.net.Inet4Address java.net.Inet6Address)
 
(doseq [addr (InetAddress/getAllByName "www.kame.net")]
(cond
(instance? Inet4Address addr) (println "IPv4:" (.getHostAddress addr))
(instance? Inet6Address addr) (println "IPv6:" (.getHostAddress addr))))</langsyntaxhighlight>
Output:
<pre>IPv4: 203.178.141.194
Line 547:
 
=={{header|CoffeeScript}}==
<langsyntaxhighlight lang="coffeescript">
# runs under node.js
dns = require 'dns'
Line 558:
console.log 'IP6'
console.log addresses
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
common lisp does not have a standard network api. the following examples are using native implementations
{{works with|SBCL}}
<langsyntaxhighlight lang="lisp">(sb-bsd-sockets:host-ent-addresses
(sb-bsd-sockets:get-host-by-name "www.rosettacode.org"))
(#(71 19 147 227))</langsyntaxhighlight>
{{works with|CMUCL}}
<langsyntaxhighlight lang="lisp">(let ((hostname (extensions:lookup-host-entry "www.rosettacode.org")))
(print (map 'list #'extensions:ip-string (host-entry-addr-list hostname))))
("71.19.147.227")</langsyntaxhighlight>
{{works with|Clozure}}
<langsyntaxhighlight lang="lisp">(ipaddr-to-dotted (lookup-hostname "www.rosettacode.org"))
"104.28.10.103"</langsyntaxhighlight>
{{works with|Clisp}}
<langsyntaxhighlight lang="lisp">(hostent-addr-list (resolve-host-ipaddr "www.rosettacode.org"))
("104.28.11.103" "104.28.10.103")</langsyntaxhighlight>
the usocket library contains a (get-hosts-by-name) function in all of its [http://trac.common-lisp.net/usocket/browser/usocket/trunk/backend backends]. unfortunately it does not expose the functions in its public interface. but since the license is MIT, it may be a suitable source to copy code for your own use.
 
{{libheader|iolib}} is a portable library that:
{{works with|SBCL}}{{works with|CMUCL}}{{works with|Clisp}}{{works with|Clozure}}
<langsyntaxhighlight lang="lisp">(iolib:lookup-hostname "www.kame.net" :ipv6 t)
 
#/IOLIB.SOCKETS:IP/203.178.141.194
Line 586:
"orange.kame.net"
(("orange.kame.net" . #/IOLIB.SOCKETS:IP/203.178.141.194)
("orange.kame.net" . #/IOLIB.SOCKETS:IP/2001:200:dff:fff1:216:3eff:feb1:44d7))</langsyntaxhighlight>
 
In Allegro Common Lisp there's a nice standard library called [http://franz.com/support/documentation/current/doc/socket.htm socket].
{{works with|Allegro}}
<langsyntaxhighlight lang="lisp">(socket:ipaddr-to-dotted
(socket:dns-query "www.rosettacode.org"))
"104.28.10.103"</langsyntaxhighlight>
 
In Lispworks the [http://www.lispworks.com/documentation/lw71/LW/html/lw-269.htm COMM] package provides information about IP addresses.
 
{{works with|Lispworks}}
<langsyntaxhighlight lang="lisp">(require "comm")
(comm:ip-address-string (comm:get-host-entry "www.rosettacode.org" :fields '(:address)))
"104.28.10.103"
</syntaxhighlight>
</lang>
 
=={{header|Crystal}}==
<langsyntaxhighlight lang="ruby">require "socket"
 
Socket::Addrinfo.resolve(
Line 611:
).each { |a|
puts a.ip_address.address
}</langsyntaxhighlight>
{{out}}
<pre>
Line 619:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">import std.stdio, std.socket;
 
void main() {
Line 629:
a = getAddressInfo(domain, port, AddressFamily.INET6);
writefln("IPv6 address for %s: %s", domain, a[0].address);
}</langsyntaxhighlight>
<pre>IPv4 address for www.kame.net: 203.178.141.194:80
IPv6 address for www.kame.net: [2001:200:dff:fff1:216:3eff:feb1:44d7]:80</pre>
Line 636:
The included Indy components wrap GetAddressInfo.
 
<langsyntaxhighlight Delphilang="delphi">program DNSQuerying;
 
{$APPTYPE CONSOLE}
Line 656:
lStack.Free;
end;
end.</langsyntaxhighlight>
 
Output:
Line 664:
 
=={{header|Erlang}}==
<syntaxhighlight lang="erlang">
<lang Erlang>
33> {ok, {hostent, Host, Aliases, AddrType, Bytes, AddrList}} = inet:gethostbyname("www.kame.net", inet).
{ok,{hostent,"orange.kame.net",
Line 679:
37> [inet_parse:ntoa(Addr) || Addr <- AddrList].
["2001:200:DFF:FFF1:216:3EFF:FEB1:44D7"]
</syntaxhighlight>
</lang>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: dns io kernel sequences ;
 
"www.kame.net" [ dns-A-query ] [ dns-AAAA-query ] bi
[ message>names second print ] bi@</langsyntaxhighlight>
{{out}}
<pre>
Line 693:
 
=={{header|Frink}}==
<langsyntaxhighlight lang="frink">for a = callJava["java.net.InetAddress", "getAllByName", "www.kame.net"]
println[a.getHostAddress[]]</langsyntaxhighlight>
{{out}}
<pre>
Line 703:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 716:
fmt.Println(err)
}
}</langsyntaxhighlight>
Output:
<pre>
Line 723:
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">def addresses = InetAddress.getAllByName('www.kame.net')
println "IPv4: ${addresses.find { it instanceof Inet4Address }?.hostAddress}"
println "IPv6: ${addresses.find { it instanceof Inet6Address }?.hostAddress}"</langsyntaxhighlight>
Output:
<pre>IPv4: 203.178.141.194
Line 731:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">module Main where
 
import Network.Socket
Line 747:
main = showIPs "www.kame.net"
</syntaxhighlight>
</lang>
Output:
<pre>
Line 759:
The following was tested only in Unicon:
 
<langsyntaxhighlight lang="unicon">
procedure main(A)
host := gethost( A[1] | "www.kame.net") | stop("can't translate")
write(host.name, ": ", host.addresses)
end
</syntaxhighlight>
</lang>
 
Sample Run:
Line 785:
Anyways:
 
<langsyntaxhighlight Jlang="j"> 2!:0'dig -4 +short www.kame.net'
orange.kame.net.
203.178.141.194
Line 791:
2!:0'dig -6 +short www.kame.net'
|interface error
| 2!:0'dig -6 +short www.kame.net'</langsyntaxhighlight>
 
Put differently: in the IPv4 DNS system, www.kame.net is currently a CNAME record for orange.kame.net which had the address 203.178.141.194.
Line 798:
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.Inet6Address;
Line 819:
}
}
</syntaxhighlight>
</lang>
Output:
<pre>
Line 827:
 
=={{header|JavaScript}}==
<langsyntaxhighlight JavaScriptlang="javascript">const dns = require("dns");
 
dns.lookup("www.kame.net", {
Line 835:
console.log(addresses);
})
</syntaxhighlight>
</lang>
Output:
<pre>
Line 844:
=={{header|Julia}}==
As entered at the REPL command line:
<langsyntaxhighlight lang="julia">
julia> using Sockets
 
Line 853:
ip"2001:200:dff:fff1:216:3eff:feb1:44d7"
 
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">// version 1.1.3
 
import java.net.InetAddress
Line 882:
fun main(args: Array<String>) {
showIPAddresses("www.kame.net")
}</langsyntaxhighlight>
 
{{out}}
Line 894:
=={{header|Lasso}}==
The DNS lookup methods in Lasso do not support IPv6 addresses at this time, only IPv4.
<langsyntaxhighlight Lassolang="lasso">dns_lookup('www.kame.net', -type='A')</langsyntaxhighlight>
 
=={{header|Lua}}==
Line 900:
{{libheader|LuaSocket}}
 
<langsyntaxhighlight lang="lua">local socket = require('socket')
local ip_tbl = socket.dns.getaddrinfo('www.kame.net')
 
Line 906:
io.write(string.format('%s: %s\n', v.family, v.addr))
end
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 916:
Neko does not yet support ipv6. ipv4 addresses are returned as Int32.
 
<langsyntaxhighlight ActionScriptlang="actionscript">/* dns in neko */
var host_resolve = $loader.loadprim("std@host_resolve", 1);
var host_to_string = $loader.loadprim("std@host_to_string", 1);
Line 924:
 
$print("www.kame.net: ", ip, ", ", host_to_string(ip), "\n");
$print(host_to_string(ip), ": ", host_reverse(ip), "\n");</langsyntaxhighlight>
 
{{out}}
Line 933:
 
=={{header|NetRexx}}==
<langsyntaxhighlight lang="netrexx">
/* NetRexx */
options replace format comments java crossref symbols nobinary
Line 947:
end
end ir
</syntaxhighlight>
</lang>
;Output
<pre>
Line 955:
 
=={{header|NewLISP}}==
<syntaxhighlight lang="newlisp">
<lang newLISP>
 
(define (dnsLookup site , ipv)
Line 968:
 
(dnsLookup "www.kame.net")
</syntaxhighlight>
</lang>
;Output
<pre>
Line 977:
=={{header|Nim}}==
 
<langsyntaxhighlight lang="nim">import nativesockets
 
iterator items(ai: ptr AddrInfo): ptr AddrInfo =
Line 992:
echo getAddrString i.aiAddr
 
when isMainModule: main()</langsyntaxhighlight>
 
{{out}}
Line 1,001:
{{Works with|oo2c version 2}}
IO:Address module supports only IPv4
<langsyntaxhighlight lang="oberon2">
MODULE DNSQuery;
IMPORT
Line 1,018:
Do;
END DNSQuery.
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 1,025:
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">use System.IO.Net;
 
class Rosetta {
Line 1,034:
};
}
}</langsyntaxhighlight>
 
Output:
Line 1,043:
=={{header|OCaml}}==
 
<langsyntaxhighlight lang="ocaml">let dns_query ~host ~ai_family =
let opts = [
Unix.AI_FAMILY ai_family;
Line 1,062:
Printf.printf " IPv4 address: %s\n" (dns_query host Unix.PF_INET);
Printf.printf " IPv6 address: %s\n" (dns_query host Unix.PF_INET6);
;;</langsyntaxhighlight>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use feature 'say';
use Socket qw(getaddrinfo getnameinfo);
 
Line 1,071:
die "getaddrinfo error: $err" if $err;
 
say ((getnameinfo($_->{addr}, Socket::NI_NUMERICHOST))[1]) for @res</langsyntaxhighlight>
{{out}}
<pre>203.178.141.194
Line 1,079:
Translated from C/MSDN/several man pages.<br>
<b>NB:</b> may warrant further testing, see output.
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">cffi</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 1,223:
<span style="color: #0000FF;">?</span><span style="color: #000000;">get_name_info</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"www.kame.net"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">WSACleanup</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
{{out}}
Note that windows nslookup shows an IPv6 that this does not, whereas
Line 1,244:
=={{header|PHP}}==
Works for PHP5 (Windows > 5.3.0)
<langsyntaxhighlight lang="php"><?php
$ipv4_record = dns_get_record("www.kame.net",DNS_A);
$ipv6_record = dns_get_record("www.kame.net",DNS_AAAA);
print "ipv4: " . $ipv4_record[0]["ip"] . "\n";
print "ipv6: " . $ipv6_record[0]["ipv6"] . "\n";
?></langsyntaxhighlight>
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(make
(in '(host "www.kame.net")
(while (from "address ")
(link (till "^J" T)) ) ) )</langsyntaxhighlight>
Output:
<pre>-> ("203.178.141.194" "2001:200:dff:fff1:216:3eff:feb1:44d7")</pre>
Line 1,261:
=={{header|Pike}}==
 
<syntaxhighlight lang="pike">
<lang Pike>
> array ips = Protocols.DNS.gethostbyname("www.kame.net")[1] || ({});
> write(ips*"\n");
</syntaxhighlight>
</lang>
Output:
<pre>203.178.141.194
Line 1,270:
 
=={{header|PowerShell}}==
<langsyntaxhighlight lang="powershell">$DNS = Resolve-DnsName -Name www.kame.net
Write-Host "IPv4:" $DNS.IP4Address "`nIPv6:" $DNS.IP6Address</langsyntaxhighlight>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">>>> import socket
>>> ips = set(i[4][0] for i in socket.getaddrinfo('www.kame.net', 80))
>>> for ip in ips: print ip
...
2001:200:dff:fff1:216:3eff:feb1:44d7
203.178.141.194</langsyntaxhighlight>
 
=={{header|R}}==
Line 1,287:
If the following is saved as <tt>dns.cpp</tt>:
 
<langsyntaxhighlight lang="cpp">
#include <Rcpp.h>
#include <arpa/inet.h>
Line 1,335:
 
}
</syntaxhighlight>
</lang>
 
It can be used to perform the task in R:
 
<syntaxhighlight lang="r">
<lang R>
library(Rcpp)
sourceCpp("dns.cpp")
Line 1,345:
## [1] "203.178.141.194"
## [2] "2001:200:dff:fff1:216:3eff:feb1:44d7"
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
Line 1,351:
The following finds an IPv4 address. Currently, the API does not support returning an IPv6 address.
 
<langsyntaxhighlight lang="racket">
#lang racket
 
(require net/dns)
(dns-get-address "8.8.8.8" "www.kame.net")
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
Line 1,362:
{{works with|Rakudo|2017.01}}
 
<syntaxhighlight lang="raku" perl6line>use Net::DNS;
 
my $resolver = Net::DNS.new('8.8.8.8');
Line 1,370:
 
say $ip4[0].octets.join: '.';
say $ip6[0].octets.».fmt("%.2X").join.comb(4).join: ':';</langsyntaxhighlight>
{{out}}
<pre>203.178.141.194
Line 1,379:
 
Execution note: &nbsp; if the information for &nbsp; &nbsp; '''PING &nbsp; -6 &nbsp; ···''' &nbsp; &nbsp; is blank, you may need to install &nbsp; (on some <br>Microsoft Windows systems) &nbsp; the IPV6 interface using the command: &nbsp; &nbsp; ''' IPV6 &nbsp; install '''
<langsyntaxhighlight lang="rexx">/*REXX program displays IPV4 and IPV6 addresses for a supplied domain name.*/
parse arg tar . /*obtain optional domain name from C.L.*/
if tar=='' then tar= 'www.kame.net' /*Not specified? Then use the default.*/
Line 1,394:
end /*j*/ /* └─◄ force (TEMP) file integrity.*/
/*stick a fork in it, we're all done. */
'ERASE' tFID /*clean up (delete) the temporary file.*/</langsyntaxhighlight>
'''output''' &nbsp; using the default input:
<pre>
Line 1,402:
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">irb(main):001:0> require 'socket'
=> true
irb(main):002:0> Addrinfo.getaddrinfo("www.kame.net", nil, nil, :DGRAM) \
irb(main):003:0* .map! { |ai| ai.ip_address }
=> ["203.178.141.194", "2001:200:dff:fff1:216:3eff:feb1:44d7"]</langsyntaxhighlight>
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">use std::net::ToSocketAddrs;
 
fn main() {
Line 1,424:
println!("{}", ip_port.ip());
}
}</langsyntaxhighlight>
 
Output:<pre>203.178.141.194
Line 1,431:
=={{header|Scala}}==
{{libheader|Scala}}
<langsyntaxhighlight Scalalang="scala">import java.net._
 
InetAddress.getAllByName("www.kame.net").foreach(x => println(x.getHostAddress))</langsyntaxhighlight>
 
=={{header|Scheme}}==
{{works with|Guile}}
<langsyntaxhighlight lang="scheme">; Query DNS
(define n (car (hostent:addr-list (gethost "www.kame.net"))))
 
Line 1,443:
(display (inet-ntoa n))(newline)
(display (inet-ntop AF_INET n))(newline)
(display (inet-ntop AF_INET6 n))(newline)</langsyntaxhighlight>
Output:<pre>203.178.141.194
203.178.141.194
Line 1,454:
The function [http://seed7.sourceforge.net/libraries/socket.htm#numericAddress%28in_socketAddress%29 numericAddress]
is used to get the IP address of the specified host.
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "socket.s7i";
 
Line 1,460:
begin
writeln(numericAddress(inetSocketAddress("www.kame.net", 1024)));
end func;</langsyntaxhighlight>
 
Output:
Line 1,468:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">var (err, *res) = Socket.getaddrinfo(
'www.kame.net', 0,
Hash.new(protocol => Socket.IPPROTO_TCP)
Line 1,475:
res.each { |z|
say [Socket.getnameinfo(z{:addr}, Socket.NI_NUMERICHOST)][1];
}</langsyntaxhighlight>
 
{{out}}
Line 1,485:
=={{header|Standard ML}}==
The basis library provides IPv4 support only:
<langsyntaxhighlight lang="sml">- Option.map (NetHostDB.toString o NetHostDB.addr) (NetHostDB.getByName "www.kame.net");
val it = SOME "203.178.141.194": string option</langsyntaxhighlight>
 
=={{header|Tcl}}==
Line 1,492:
{{tcllib|dns}}
{{libheader|udp}}
<langsyntaxhighlight lang="tcl">package require udp; # Query by UDP more widely supported, but requires external package
package require dns
 
Line 1,501:
update; # Let queries complete
}
puts "primary addresses of $host are:\n\tIPv4» [dns::address $v4]\n\tIPv6» [dns::address $v6]"</langsyntaxhighlight>
Output:
<pre>
Line 1,511:
=={{header|UNIX Shell}}==
===Using dig===
<langsyntaxhighlight lang="bash">
Aamrun ~ % dig www.kame.net A www.kame.net AAAA +short
mango.itojun.org.
Line 1,519:
2001:2f0:0:8800::1:1
Aamrun ~ %
</syntaxhighlight>
</lang>
===Using nslookup===
<langsyntaxhighlight lang="bash">
Aamrun ~ % nslookup
> set q=AAAA
Line 1,546:
 
Aamrun ~ %
</syntaxhighlight>
</lang>
 
=={{header|VBScript}}==
<syntaxhighlight lang="vb">
<lang vb>
Function dns_query(url,ver)
Set r = New RegExp
Line 1,566:
 
Call dns_query(WScript.Arguments(0),WScript.Arguments(1))
</syntaxhighlight>
</lang>
 
{{Out}}
Line 1,583:
 
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to do it for us.
<langsyntaxhighlight lang="ecmascript">/* dns_query.wren */
 
class Net {
Line 1,591:
var host = "orange.kame.net"
var addrs = Net.lookupHost(host).split(", ")
System.print(addrs.join("\n"))</langsyntaxhighlight>
which we embed in the following Go program and run it:
{{libheader|WrenGo}}
<langsyntaxhighlight lang="go">/* go run dns_query.go */
 
package main
Line 1,624:
vm.InterpretFile(fileName)
vm.Free()
}</langsyntaxhighlight>
 
{{out}}
Line 1,634:
=={{header|zkl}}==
The addrInfo method is just a front end to POSIX getaddrinfo.
<langsyntaxhighlight lang="zkl">zkl: Network.TCPClientSocket.addrInfo("www.kame.net")
L("orange.kame.net",L("203.178.141.194","2001:200:dff:fff1:216:3eff:feb1:44d7"))</langsyntaxhighlight>
 
 
10,327

edits