# The EventDnsBase class

(PECL event >= 1.2.6-beta)

## 简介

Represents Libevent's DNS base structure. Used to resolve DNS asyncronously, parse configuration files like resolv.conf etc.

## 类摘要

final class EventDnsBase {
/* 常量 */
const int OPTION_SEARCH = 1;
const int OPTION_NAMESERVERS = 2;
const int OPTION_MISC = 4;
const int OPTION_HOSTSFILE = 8;
const int OPTIONS_ALL = 15;
const int DISABLE_WHEN_INACTIVE = 32768;
const int INITIALIZE_NAMESERVERS = 1;
const int NAMESERVERS_NO_DEFAULT = 65536;
/* 方法 */
public __construct( EventBase `$base` , int|bool `$initialize` )
public addNameserverIp( string `$ip` ): bool
public addSearch( string `$domain` ): void
public clearSearch(): void
public countNameservers(): int
public loadHosts( string `$hosts` ): bool
public parseResolvConf( int `$flags` , string `$filename` ): bool
public setOption( string `$option` , string `$value` ): bool
public setSearchNdots( int `$ndots` ): bool
}

## 预定义常量

`EventDnsBase::OPTION_SEARCH`

  Tells to read the domain and search fields from the `resolv.conf` file and the `ndots` option, and use them to decide which domains(if any) to search for hostnames that aren’t fully-qualified.

`EventDnsBase::OPTION_NAMESERVERS`

  Tells to learn the nameservers from the `resolv.conf` file.

`EventDnsBase::OPTION_MISC`

`EventDnsBase::OPTION_HOSTSFILE`

  Tells to read a list of hosts from `/etc/hosts` as part of loading the `resolv.conf` file.

`EventDnsBase::OPTIONS_ALL`

  Tells to learn as much as it can from the `resolv.conf` file.

`EventDnsBase::DISABLE_WHEN_INACTIVE`

  Do not prevent the libevent event loop from exiting when we have no active DNS requests.

`EventDnsBase::INITIALIZE_NAMESERVERS`

  Process the `resolv.conf`.

`EventDnsBase::NAMESERVERS_NO_DEFAULT`

  Do not add default nameserver if there are no nameservers in the `resolv.conf`.

## 目录

- EventDnsBase::addNameserverIp — Adds a nameserver to the DNS base
- EventDnsBase::addSearch — Adds a domain to the list of search domains
- EventDnsBase::clearSearch — Removes all current search suffixes
- EventDnsBase::__construct — Constructs EventDnsBase object
- EventDnsBase::countNameservers — Gets the number of configured nameservers
- EventDnsBase::loadHosts — Loads a hosts file (in the same format as /etc/hosts) from hosts file
- EventDnsBase::parseResolvConf — Scans the resolv.conf-formatted file
- EventDnsBase::setOption — Set the value of a configuration option
- EventDnsBase::setSearchNdots — Set the 'ndots' parameter for searches

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open