friendev EtherDune TCP/IP library
Public Member Functions | Friends | List of all members
DNSClient Class Reference

EtherDune DNS Service. More...

#include <DNS.h>

Inheritance diagram for DNSClient:
UDPSocket

Public Member Functions

uint16_t resolve (const char *name)
 Resolves a host name to an IP address More...
 

Friends

class NetworkService
 

Detailed Description

EtherDune DNS Service.

Implements the basics of DNS so as to resolve hostnames to IP addresses. See DNS configuration for EtherDune config parameters that apply to DNS.

You cannot create an instance of this class. In order to use DNS in your project, access the singleton instance in net::DNS() this way:

uint16_t id = net::DNS().resolve("www.friendev.com");

To resolve a hostname to an IP Address, call the resolve method and save the uint16_t result as an identification token to match possible responses to your request.

To receive the reply, override the onDNSResolve virtual function on any NetworkService-derived class and match the identification to the token you received from resolve.

Most classes have this mechanism already automatically implemented, providing overloads that take a host name as opposed to an IP address.

EtherDune is designed in such a way that if you do not call net::DNS() within your code, DNS functions won't be compiled in, thus saving space.

DNS code will be compiled in if, however, you use any other function within EtherDune that in turn requires DNS to work such as HTTPClient::request, which takes in a hostname as a parameter and thus uses net::DNS() internally.

See DNSDemo.ino for a simple demonstration application that uses DNS alone.

Definition at line 52 of file DNS.h.

Member Function Documentation

uint16_t DNSClient::resolve ( const char *  name)

Resolves a host name to an IP address

Parameters
namehost name to resolve
Returns
Returns an numeric id token to match against the identification parameter of onDNSResolve virtual callback function

Definition at line 45 of file DNS.cpp.

Friends And Related Function Documentation

friend class NetworkService
friend

Definition at line 54 of file DNS.h.


The documentation for this class was generated from the following files: