public function negotiateTelnetOptions() {

        $c = $this->getc();

        if ($c != $this->IAC) {

            if (($c == $this->DO) || ($c == $this->DONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->WONT . $opt);
            } else if (($c == $this->WILL) || ($c == $this->WONT)) {

                $opt = $this->getc();
                fwrite($this->socket, $this->IAC . $this->DONT . $opt);
            } else {
                throw new \Exception('Error: unknown control character ' . ord($c));
            }
        } else {
            throw new \Exception('Error: Something Wicked Happened');
        }

        return true;
    }