protected function read($len)
    {
        $contents   = "";
        $clen       = 0;
        while (!feof($this->socket) && $clen < $len) {
            $read = fread($this->socket, $len - $clen);
            if ($read === false) {
                throw new \Erebot\Exception('Connection closed by proxy');
            }
            $contents  .= $read;
            $clen       = strlen($contents);
        }
        return $contents;
    }