dns_loop()


接收DNS查询的应答返还结果

Description

string dns_loop(void)

Parameters

none

Return Value

成功时IP地址,失败时空字符串 (“”)或是没有接收到DNS应答时false

Example

<?php
include "/lib/sn_dns.php";
$rr = "";
$name = "www.phpoc.com";
dns_setup(0);                // UDP ID 0, and system DSN server IP addesss
dns_send_query($name, RR_A); // sending query for www.phpoc.com
while(1)
{
  $rr = dns_loop();          // receiving response from the DNS server
  if($rr === false)
    usleep(1000);
  elseif($rr == "")
  {
    echo $name, "r\r\n";     // outputting domain name
    break;
  }
  else
  {
    echo "$rr\r\n";          // outputting DNS server's response
    break;
  }
}
?>

See also