Read data from incoming POP3 stream.

@param integer $size  UNUSED: The number of bytes to read from the
socket.

@return string  Line of data.

@throws Horde_Imap_Client_Exception
12403
public function read($size = null)
    {
        if (feof($this->_stream)) {
            $this->close();
            $this->_params['debug']->info(
                'ERROR: Server closed the connection.'
            );
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Server closed the connection unexpectedly."),
                Horde_Imap_Client_Exception::DISCONNECT
            );
        }

        if (($read = fgets($this->_stream)) === false) {
            $this->_params['debug']->info('ERROR: read/timeout error.');
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Error when communicating with the mail server."),
                Horde_Imap_Client_Exception::SERVER_READERROR
            );
        }

        $this->_params['debug']->server(rtrim($read, "\r\n"));

        return $read;
    }
1027280
protected function readHeaderRaw($size)
    {
        if ($this->position + $size > $this->headerSize) {
            throw new \Exception('Can\'t read ' . $size . ' bytes');
        }
        $data = substr($this->header, $this->position, $size);
        $this->position += $size;
        return $data;
    }
917411
public function stream_read($count)
    {
        $ret = substr($this->_data, $this->_pos, $count);
        $this->_pos += strlen($ret);
        return $ret;
    }
169575
public ByteArray readBytes(int size) throws IOException
   {
      byte[] data = new byte[size];
      m_stream.read(data);
      return new ByteArray(data);
   }
874007
public function read($size = 8192)
    {
        $buf = @fread($this->sock, $size);
        if ($buf === '' || $buf === false) {
            $buf = $this->ioEmptyError() ? false : null;
        }
        $this->ioFlagReset();
        return $buf;
    }
6734
public function receiveMessage($length = null)
    {
        if (null === $length)
            return stream_get_contents($this->getSocketStream());
        $response = null;
        while ($chunk = fread($this->getSocketStream(), 1024)) {
            $response .= $chunk;
            if (substr($chunk, -1) === "\n") {
                break;
            }
        }
        return $response;
    }
726425
public function translateBytes($size)
    {
        $units = [
            'k' => 1,
            'm' => 2,
            'g' => 3,
            't' => 4,
            'p' => 5
        ];
        $size = strtolower($size);
        $bytes = intval($size);
        foreach ($units as $key => $value) {
            if (strpos($size, $key)) {
                $bytes = $bytes * pow(1024, $value);
                break;
            }
        }
        return $bytes;
    }
968919
public function read($len) {
        // Do a non-blocking read to clear any buffering, even though
        // the code doesn't use the results
        if (is_resource($this->socket_)) {
            @fread($this->socket_, max($len, 8192));
        }

        // Return data from the hard-coded response buffer
        $part = substr($this->respBuffer_, 0, $len);
        $this->respBuffer_ = substr($this->respBuffer_, $len);
        return $part;
    }
1246450
public function read($length)
    {
        $streamResource = $this->getStreamResource();
        if (!is_resource($streamResource)) {
            throw new \UnexpectedValueException('Stream resource parameter must be a resource');
        }
        $streamsRead   = array($streamResource);
        $streamsWrite  = NULL;
        $streamsExcept = NULL;

        $hasDataToRead = stream_select(
            $streamsRead,
            $streamsWrite,
            $streamsExcept,
            0
        );

        if ($hasDataToRead) {
            return fread($streamResource, $length);
        }
        return false;
    }
406969
public function gets($size)
    {
        $this->_checkStream();
        $data = @fgets($this->_stream, $size);
        if ($data === false) {
            throw new Client\Exception('Error reading data from socket');
        }
        return $data;
    }
430104
protected function readHeader($type, $size)
    {
        if ($this->position + $size > $this->headerSize) {
            throw new \Exception('Can\'t read ' . $size . ' bytes');
        }
        $data = unpack($type, substr($this->header, $this->position, $size));
        $this->position += $size;
        return $data[1];
    }
254046
public function read($length){
        if(!is_int($length)){
            throw new \InvalidArgumentException();
        }

        if(null === $this->resource){
            throw new Exception\StreamUnavailableException(
                static::EXCEPTION_MSG_UNAVAILABLE
            );
        }

        if(!$this->isReadable()){
            throw new Exception\StreamUnreadableException(
                static::EXCEPTION_MSG_UNREADABLE
            );
        }

        if(false === ($contents = fread($this->resource, $length))){
            throw new \RuntimeException("Failed to read stream.");
        }

        return $contents;
    }
1003324
public function readLine($length = null) {
        $this->openRead();
        if (empty($length)) {
            return fgets($this->stream);
        }
        return fgets($this->stream, $length);
    }
5724
protected function _read($length = null) {
		if (!$this->connected) {
			$message = 'No connection found while reading data from socket.';
			throw new RuntimeException($message);
		}
		if ($length) {
			if (feof($this->_connection)) {
				return false;
			}
			$data = stream_get_contents($this->_connection, $length + 2);
			$meta = stream_get_meta_data($this->_connection);

			if ($meta['timed_out']) {
				$message = 'Connection timed out while reading data from socket.';
				throw new RuntimeException($message);
			}
			$packet = rtrim($data, "\r\n");
		} else {
			$packet = stream_get_line($this->_connection, 16384, "\r\n");
		}
		return $packet;
	}
795786
public function stream_read($length)
    {
        $data = substr($this->_data, $this->_position, $length);
        $this->_position += strlen($data);

        return $data;
    }
853812
public function read($count)
    {
        $contentLength = strlen($this->data);
        if ($this->position > $contentLength || $count > $contentLength - $this->position) {
            throw new EndOfStreamException(
                sprintf(
                    'End of stream reached when trying to read %d bytes. content length=%d, position=%d',
                    $count,
                    $contentLength,
                    $this->position
                )
            );
        }

        $chunk = substr($this->data, $this->position, $count);
        if ($chunk === false) {
            $chunk = '';
        }

        $readBytes = strlen($chunk);
        $this->position += $readBytes;

        return $chunk;
    }
1250212
public function stream_read($count) {
		$returner = substr($this->entry['data'], $this->pos, $count);
		// update position
		$this->pos = min($this->pos + $count, strlen($this->entry['data']));
		return $returner;
	}