readPacket

abstract suspend fun readPacket(
    size: Int,
    headerSizeHint: Int = 0
): ByteReadPacket

Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available. Accepts headerSizeHint to be provided, see WritePacket.