modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of DnsQuery by Sarah Marsh

Files at this revision

API Documentation at this revision

Comitter:
ohneta
Date:
Wed Nov 11 03:39:26 2015 +0000
Parent:
4:7e64d099f63e
Commit message:
added timeout=1000ms on "Receive the answer from DNS?

Changed in this revision

DnsQuery.cpp Show annotated file Show diff for this revision Revisions of this file
DnsQuery.h Show annotated file Show diff for this revision Revisions of this file
diff -r 7e64d099f63e -r 7555d509b568 DnsQuery.cpp
--- a/DnsQuery.cpp	Tue Nov 10 14:37:17 2015 +0000
+++ b/DnsQuery.cpp	Wed Nov 11 03:39:26 2015 +0000
@@ -37,16 +37,17 @@
 
 
 
-DnsQuery::DnsQuery(SocketInterface *sock, const char* hostname, char* ipaddress, const char *dnsIp)
+
+DnsQuery::DnsQuery(SocketInterface *sock, const char* hostname, char* ipaddress, const char *preferreddnsIp)
 {
     socket = sock;
-    this->setPreferredDNSServerIP(dnsIp);
+    this->setPreferredDNSServerIP(preferreddnsIp);
     this->getHostByName(hostname, ipaddress);
 }
 
-void DnsQuery::setPreferredDNSServerIP(const char *dnsIp)
+void DnsQuery::setPreferredDNSServerIP(const char *preferreddnsIp)
 {
-    _preferred_dnsip = dnsIp;
+    _preferred_dnsip = preferreddnsIp;
 }
 
 bool DnsQuery::getHostByName(const char* hostname, char* resolvedIp)
@@ -144,7 +145,7 @@
     //  Receive the answer from DNS
     int response_length = 0;
     INFO("Recieving");
-    response_length = socket->recv(packet, 1024);
+    response_length = socket->recv(packet, 1024, 1000);  // todo !!
         /*
         for( int i = 0 ; i < 1024; i++) {
             printf("%02x ", packet[i]);
diff -r 7e64d099f63e -r 7555d509b568 DnsQuery.h
--- a/DnsQuery.h	Tue Nov 10 14:37:17 2015 +0000
+++ b/DnsQuery.h	Wed Nov 11 03:39:26 2015 +0000
@@ -25,9 +25,9 @@
     /** Constructor to instantiate a DnsQuery object.
       * @param wifi : A valid pointer to a UDP socket
       */
-    DnsQuery(SocketInterface* sock,const char* hostname, char* ipaddress, const char *dnsIp = NULL);
+    DnsQuery(SocketInterface* sock,const char* hostname, char* ipaddress, const char *preferreddnsIp = NULL);
  
-    void setPreferredDNSServerIP(const char *dnsIp);  
+    void setPreferredDNSServerIP(const char *preferreddnsIp);  
 private:   
     /** Function gethostbyname implements the functionality to query a domain name server for an IP-Address of a given hostname.
       * @param hostname : the hostname of interest as a string - format must be without http:// or www. IE google.com, mbed.org, etc