PHPDaemon\Clients\DNS\Connection::get PHP Метод

get() публичный Метод

Gets the host information
public get ( string $hostname, callable $cb ) : void
$hostname string Hostname
$cb callable Callback
Результат void
    public function get($hostname, $cb)
    {
        $this->onResponse->push($cb);
        $this->setFree(false);
        $e = explode(':', $hostname, 3);
        $hostname = $e[0];
        $qtype = isset($e[1]) ? $e[1] : 'A';
        $qclass = isset($e[2]) ? $e[2] : 'IN';
        $QD = [];
        $qtypeInt = array_search($qtype, Pool::$type, true);
        $qclassInt = array_search($qclass, Pool::$class, true);
        if ($qtypeInt === false || $qclassInt === false) {
            $cb(false);
            return;
        }
        $q = Binary::labels($hostname) . Binary::word($qtypeInt) . Binary::word($qclassInt);
        $QD[] = $q;
        $packet = Binary::word(++$this->seq) . Binary::bitmap2bytes('0' . '0000' . '0' . '0' . '1' . '0' . '000' . '0000', 2) . Binary::word(sizeof($QD)) . Binary::word(0) . Binary::word(0) . Binary::word(0) . implode('', $QD);
        if ($this->type === 'udp') {
            $this->write($packet);
        } else {
            $this->write(Binary::word(mb_orig_strlen($packet)) . $packet);
        }
    }