tres

Artifact [e4af0da0f3]
Login

Artifact e4af0da0f3fad30216caa700e2f5fc3edcfaa31f:

Wiki page [tres] by aspect 2015-03-10 23:55:18.
D 2015-03-10T23:55:18.172
L tres
P dba55a6290841f341487dd65c388dbe33d926193
U aspect
W 2359
<tt>tres</tt> is a featherweight threaded resolver for POSIX.  It currently consists of a single stand-alone test program that takes hosts to resolve on the command line and on stdin, echoing the results back on stdout.

It has been tested on Linux+gcc and FreeBSD+clang, and I'm fairly confident it should work in other POSIX environments.  Unfortunately, the test harness isn't terribly scriptable without either a <tt>ares_wait()</tt> method or more smarts in the test program.  The latter is more appealing, as the former requires much more smarts in my dumb dispatcher and will push past the 500loc and almost braindead ignorance of most of the pthread API.

The goal is eventually to adapt this to <tt>Tcl_Thread</tt> such that it can be applied to the Tcl core and make asynchronous sockets truly asynchronous.  There are a few bridges to cross first, and this isn't a high-priority project for me, so don't hold your breath.

<h2>Testing</h2>

Just <tt>make</tt> to build the executable <tt>ares</tt>.  Run it with 0 or more hostnames to resolve on the command line.  You can give more hostnames on <tt>stdin</tt> (one per line) to get those resolved too.

An empty line on <tt>stdin</tt> will cause it to prune unused resolver threads.  <tt>EOF</tt> will cause it to exit.

Hosts are resolved asynchronously, so output can be interleaved.  Output for a single resolution looks something like:

<pre>
request 'csiro.au'
result 'csiro.au' = '150.229.76.170'
result 'csiro.au' = '150.229.12.170'
result 'csiro.au' = '2405:b000:e00:280::12:170'
result 'csiro.au' = '2405:b000:b00:280::76:170'
result 'csiro.au' = ''
</pre>

<h2>Useful hostnames for testing</h2>

<ul>
<li><tt>localhost</tt> - returns very quickly without having to hit DNS</li>
<li><tt>nonexistent</tt> - NXDOMAIN</li>
<li><tt>example.bad.vpn.oc9.org</tt> - example of a completely down DNS server (thanks rkeene!)</li>
<li><tt>example.org</tt> - returns a single result for each of IPv4, IPv6</li>
<li><tt>$(head -c 6 /dev/random | base64).abstracted-spleen.org</tt> - a single IPv4 result that is almost guaranteed to not be in cache</li>
<li><tt>csiro.au</tt> - returns multiple IPv4 and IPv6 results</li>
<li><tt>tcl.tk</tt> - returns a single IPv4 result</li>
</ul>

Of course, some of these are allowed to change at the site administrator's whim.
Z 9eae50d46feefcbcc366e5ac1042dead