Method
StringBuffer::read
Returns up to $maxLength bytes, and waits while the buffer is empty and not ended.
Description#
public StringBuffer::read(
int $maxLength,
float $timeout = PHP_FLOAT_MAX
): stringReturns what is buffered when there is any, which may be less than $maxLength, and an empty string once the buffer has ended and is empty. A $timeout of 0 never waits: it returns what is buffered, possibly an empty string.
Parameters#
- $maxLength int
- The most bytes to return
- $timeout float = PHP_FLOAT_MAX
- Seconds to wait for data at most
Return values#
The bytes read string
Errors / Exceptions#
| Exception | When |
|---|---|
OutOfBoundsException | If $maxLength is negative |
TimeoutException | If no data arrived in time |
DeadmanException | If the writer exited without ending the buffer, once the buffered data is read |
See also#
StringBuffer::readFixedReturns exactly$lengthbytes, and waits until that many are buffered.