Method code for $dns.hostname()

[Turn off line numbering]
  1: arg ip;
  2: var c, line, result;
  3: 
  4: if (!ip)
  5:     return pass();
  6: if (!match_regexp(ip, valid_ip_regexp))
  7:     throw(~invip, "Invalid IP Address: " + ip);
  8: if (!async)
  9:     return pass(ip);
 10: if (!valid(connection)) {
 11:     if (!.restart())
 12:         return pass(ip);
 13: }
 14: connection = connection.write(task_id() + ":N:" + ip);
 15: result = $scheduler.suspend(this());
 16: if (type(result) != 'list || listlen(result) != 2)
 17:     return "";
 18: switch (result[1]) {
 19:     case "N":
 20:         throw(~address, result[2]);
 21:     case "F":
 22:         throw(~failed, result[2]);
 23:     case "G":
 24:         return result[2];
 25:     default:
 26:         $sys.log("DNS ERROR: Invalid result: " + result.join(":"));
 27: }

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

Method Ancestry Override:

 ----  172 $dns.hostname(ip)
 ---n    1 $network.hostname()

Tlon