public function setHost(string $hostname)
    {
        if (($ppos = strrpos($hostname, ":")) !== false)
        {
            $this->port = substr($hostname, $ppos + 1);
            $hostname = substr($hostname, 0, $ppos);
        }

        if (substr($hostname, 0, 4) === "xn--")
            $hostname = \idn_to_utf8($hostname);

        $this->host = strtolower($hostname);
        return $this;
    }