Method
StringBuffer::readFixed
Returns exactly $length bytes, and waits until that many are buffered.
Description#
public StringBuffer::readFixed(
int $length,
float $timeout = PHP_FLOAT_MAX
): ?stringReturns null if the buffer ends with fewer than $length bytes left; they stay in the buffer. A $timeout of 0 never waits: it returns null when $length bytes are not there yet.
Parameters#
- $length int
- The number of bytes
- $timeout float = PHP_FLOAT_MAX
- Seconds to wait at most
Return values#
The bytes, or null at the end of the buffer ?string
Errors / Exceptions#
| Exception | When |
|---|---|
TimeoutException | If $length bytes were not there in time |
DeadmanException | If the writer exited without ending the buffer |
See also#
StringBuffer::readReturns up to$maxLengthbytes, and waits while the buffer is empty and not ended.StringBuffer::unreadPuts$chunkback at the front of the buffer, to be read first.