The DNS interface is for DNS lookups. Note that this class is - while be used asynchrounosly - internal using a thread for the look up stuff.
File | common/interface/timezone.h |
Classes |
IDns UDns |
Data types |
DNS_DEFAULT_TIMEOUT |
Examples |
Code Example |
class IDns {
public:
static IDns * Create(class IIoMux * const iomux);
virtual ~IDns() {};
virtual void GetHostByName(const char * host, class UDns * const user, class IInstanceLog * const log, dword timeout = DNS_DEFAULT_TIMEOUT, bool all = false);
};
class IIoMux * const iomux | The IIoMux instance used by IDns. |
const char * host | The hostname (e. g. "innovaphone.com"). |
class UDns * user | The UDns instance callback after the name has been resolved (or an error occurred). |
class IInstanceLog * const log | The IInstanceLog instance to write logging messages to. Only used, if LOG_DNS is enabled. |
dword timeout | (Default: DNS_DEFAULT_TIMEOUT) The timeout in milliseconds to wait until the request will be canceled if the DNS server won't answer. |
bool all | (Default: false) If that flag is set, all IP addresses found for the hostname will be reported, else only the first one. |
class UDns {
public:
virtual void DnsGetHostByNameResult(const char * addr, bool isIPv6);
};
const char * addr | The TCP/IP address of the hostname given to IDns::GetHostByName(). If an error occured, addr will be nullptr. |
bool isIPv6 | True, if the address given in addr is an IPv6 address, or false, if it is IPv4. |
DNS_DEFAULT_TIMEOUT | The default timeout for DNS lookup requests (5000ms). |
app::app(IIoMux * iomux)
: iomux(iomux)
{
this->dns = IDns::Create(iomux);
this->dns->GetHostByName("innovaphone.com", this);
}
void app::DnsGetHostByNameResult(const char * addr, bool isIPv6)
{
if (addr == nullptr) debug->printf("DNS lookup of innovaphone.com failed\n");
else debug->printf("ip address of innovaphone.com = %s\n", addr);
delete this->dns;
this->dns = nullptr;
}