From 8c0f10d9d9d19fefb5acae94750ab914b333962d Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 19 Jan 2018 10:54:10 +0000 Subject: [PATCH] tcpclient : generate an exception if the DNS has an error git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4037 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- tcpclient.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tcpclient.php b/tcpclient.php index d92705f..69ba63c 100644 --- a/tcpclient.php +++ b/tcpclient.php @@ -56,7 +56,10 @@ class tcpclient $i = 0; while (empty ($this->ipv4) && empty ($this->ipv6) && $i < 10) { - $nsRecords = dns_get_record ($ipOrName, DNS_AAAA + DNS_A + DNS_CNAME); + $nsRecords = @dns_get_record ($ipOrName, DNS_AAAA + DNS_A + DNS_CNAME); + if ($nsRecords === false) + throw new \Exception ("Can not find the IP for $ipOrName : ". + "DNS Error", 500); foreach ($nsRecords as $val) { if ($val["type"] === "CNAME")