Horde_Imsp_Client_Base::receiveStringLiteral PHP Method

receiveStringLiteral() abstract public method

Receives fixed number of bytes from IMSP socket. Used when server returns a string literal.
abstract public receiveStringLiteral ( integer $length ) : string
$length integer Number of bytes to read from socket.
return string Text of string literal.
    public abstract function receiveStringLiteral($length);

Usage Example

Esempio n. 1
0
 /**
  * Function sends a GET command to IMSP server and retrieves values.
  *
  * @param  string $option  Name of option to retrieve. Accepts '*' as wild
  *                         card.
  *
  * @return array  Hash containing option=>value pairs.
  * @throws Horde_Imsp_Exception
  */
 public function get($option)
 {
     $options = array();
     $this->_imsp->send("GET {$option}", true, true);
     $server_response = $this->_imsp->receive();
     while (preg_match("/^\\* OPTION/", $server_response)) {
         /* First, check for a {}. */
         if (preg_match(Horde_Imsp_Client_Base::OCTET_COUNT, $server_response, $tempArray)) {
             $temp = explode(' ', $server_response);
             $options[$temp[2]] = $this->_imsp->receiveStringLiteral($tempArray[2]);
             $this->_imsp->receive();
         } else {
             $temp = explode(' ', $server_response);
             $options[$temp[2]] = trim($temp[3]);
             $i = 3;
             $lastChar = "";
             $nextElement = trim($temp[3]);
             /* Was the value quoted and spaced? */
             if (substr($nextElement, 0, 1) == '"' && substr($nextElement, strlen($nextElement) - 1, 1) != '"') {
                 do {
                     $nextElement = $temp[$i + 1];
                     $lastChar = substr($nextElement, strlen($nextElement) - 1, 1);
                     $options[$temp[2]] .= ' ' . $nextElement;
                     if ($lastChar == '"') {
                         $done = true;
                     } else {
                         $done = false;
                         $lastChar = substr($temp[$i + 2], strlen($temp[$i + 2]) - 1, 1);
                         $i++;
                     }
                 } while ($lastChar != '"');
                 if (!$done) {
                     $nextElement = $temp[$i + 1];
                     $options[$temp[2]] .= ' ' . $nextElement;
                 }
             }
         }
         $server_response = $this->_imsp->receive();
     }
     if ($server_response != 'OK') {
         throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
     }
     $this->_imsp->_logger->debug('GET command OK.');
     return $options;
 }
All Usage Examples Of Horde_Imsp_Client_Base::receiveStringLiteral