Method code for $dns.startup_dns()

[Turn on line numbering]
var id, tmp, x;

if (starting)
    return;
started = 0;
starting = 1;
if (connection)
    (| connection.close() |);
id = tosym("dns_connection");
while ((| lookup(id) |))
    id = tosym("dns_connection_" + ++x);
connection = $outbound_connection.new_with(id);
if ((| connection.open_connection(@dnshost) |)) {
    starting = 0;
    started = 1;
    return;
}

// try to exec() it, then startup again
(| $sys.startup_dnsserv() |);
$scheduler.sleep(1);
catch any {
    connection.open_connection(@dnshost);
    starting = 0;
} with {
    (| connection.close() |);
    connection = 0;
    starting = 0;
    if (error() == ~refused)
        throw(~refused, "Unable to open connection to " + dnshost.join(":"));
    else
        rethrow(error());
}
started = 1;

// Created 01-Jul-1997 as a part of ColdCore, see: @help Credit

Tlon