Sarah Marsh / DnsQuery

Dependents:   TempTower

Files at this revision

API Documentation at this revision

Comitter:
sarahmarshy
Date:
Thu Aug 27 14:33:07 2015 +0000
Parent:
2:12d08f0f20cf
Commit message:
Constructor calls gethostbyname;

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
--- a/DnsQuery.cpp	Wed Aug 05 21:58:57 2015 +0000
+++ b/DnsQuery.cpp	Thu Aug 27 14:33:07 2015 +0000
@@ -37,12 +37,13 @@
 
 
 
-DnsQuery::DnsQuery(SocketInterface *sock)
+DnsQuery::DnsQuery(SocketInterface *sock,const char* hostname, char* ipaddress)
 {
     socket = sock;
+    this->getHostByName(hostname, ipaddress);
 }
 
-bool DnsQuery::gethostbyname(const char* hostname, char* resolvedIp)
+bool DnsQuery::getHostByName(const char* hostname, char* resolvedIp)
 {
     char * dnsIPs[] = {
         "8.8.8.8",
--- a/DnsQuery.h	Wed Aug 05 21:58:57 2015 +0000
+++ b/DnsQuery.h	Thu Aug 27 14:33:07 2015 +0000
@@ -25,22 +25,22 @@
     /** Constructor to instantiate a DnsQuery object.
       * @param wifi : A valid pointer to a UDP socket
       */
-    DnsQuery(SocketInterface* sock);
-    
-    
+    DnsQuery(SocketInterface* sock,const char* hostname, char* ipaddress);
+ 
+   
+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
       * @param ipaddress : a reference to a IPADDRESS_t object which will receive the resolved IP Address of the host in question.
       * @returns true if successful, or false otherwise.
       */
-    bool gethostbyname(const char* hostname, char* ipaddress);
+    bool getHostByName(const char* hostname, char* ipaddress);
     /** 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.
       * @param ipaddress : a reference to a IPADDRESS_t object which will receive the resolved IP Address of the host in question.
       * @returns true if successful, or false otherwise.
       */
     bool getIP(const char* hostname, char* ipaddress);
-protected:
     bool resolve(char* resp, char* ipaddress);
     bool parseRR(char *resp, int& c, char* adr );