Poco::Net

class DNS

Library: Net
Package: NetCore
Header: Poco/Net/DNS.h

Description

This class provides an interface to the domain name service.

An internal DNS cache is used to speed up name lookups.

Member Summary

Member Functions: aierror, error, flushCache, hostByAddress, hostByName, hostName, lastError, reload, resolve, resolveOne, thisHost

Enumerations

HintFlag

DNS_HINT_NONE = 0

DNS_HINT_AI_PASSIVE = 0x00000001

DNS_HINT_AI_CANONNAME = 0x00000002

DNS_HINT_AI_NUMERICHOST = 0x00000004

DNS_HINT_AI_NUMERICSERV = 0x00001000

DNS_HINT_AI_ALL = 0x00000100

DNS_HINT_AI_ADDRCONFIG = 0x00000400

DNS_HINT_AI_V4MAPPED = 0x00000800

Member Functions

flushCache static

static void flushCache();

Deprecated. This function is deprecated and should no longer be used.

Flushes the internal DNS cache.

As of 1.4.2, the DNS cache is no longer used and this method does not do anything.

hostByAddress static

static HostEntry hostByAddress(
    const IPAddress & address,
    unsigned hintFlags = DNS_HINT_AI_CANONNAME | DNS_HINT_AI_ADDRCONFIG
);

Returns a HostEntry object containing the DNS information for the host with the given IP address. HintFlag argument is only used on platforms that have getaddrinfo().

Throws a HostNotFoundException if a host with the given name cannot be found.

Throws a DNSException in case of a general DNS error.

Throws an IOException in case of any other error.

hostByName static

static HostEntry hostByName(
    const std::string & hostname,
    unsigned hintFlags = DNS_HINT_AI_CANONNAME | DNS_HINT_AI_ADDRCONFIG
);

Returns a HostEntry object containing the DNS information for the host with the given name. HintFlag argument is only used on platforms that have getaddrinfo().

Throws a HostNotFoundException if a host with the given name cannot be found.

Throws a NoAddressFoundException if no address can be found for the hostname.

Throws a DNSException in case of a general DNS error.

Throws an IOException in case of any other error.

hostName static

static std::string hostName();

Returns the host name of this host.

reload static

static void reload();

Reloads the resolver configuration.

This method will call res_init() if the Net library has been compiled with -DPOCO_HAVE_LIBRESOLV. Otherwise it will do nothing.

resolve static

static HostEntry resolve(
    const std::string & address
);

Returns a HostEntry object containing the DNS information for the host with the given IP address or host name.

Throws a HostNotFoundException if a host with the given name cannot be found.

Throws a NoAddressFoundException if no address can be found for the hostname.

Throws a DNSException in case of a general DNS error.

Throws an IOException in case of any other error.

resolveOne static

static IPAddress resolveOne(
    const std::string & address
);

Convenience method that calls resolve(address) and returns the first address from the HostInfo.

thisHost static

static HostEntry thisHost();

Returns a HostEntry object containing the DNS information for this host.

Throws a HostNotFoundException if DNS information for this host cannot be found.

Throws a NoAddressFoundException if no address can be found for this host.

Throws a DNSException in case of a general DNS error.

Throws an IOException in case of any other error.

aierror protected static

static void aierror(
    int code,
    const std::string & arg
);

Throws an exception according to the getaddrinfo() error code.

error protected static

static void error(
    int code,
    const std::string & arg
);

Throws an exception according to the error code.

lastError protected static

static int lastError();

Returns the code of the last error.