Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Quic.Streams

Feature notes: Asynchronous QUIC server and HTTP/3 component

Classes, interfaces and records

recordtQuicStreamLimits

MaxData: UInt64; MaxStreamDataBidiLocal: UInt64; MaxStreamDataBidiRemote: UInt64; MaxStreamDataUni: UInt64; MaxStreamsBidi: UInt64; MaxStreamsUni: UInt64;

recordtQuicStreamBudgets

MaxStreams: Integer; MaxBufferedBytes: Integer; MaxRangesPerStream: Integer;

recordtQuicStreamInfo

StreamID: UInt64; SendState: tQuicStreamSendState; ReceiveState: tQuicStreamReceiveState; SendOffset: UInt64; SendLimit: UInt64; ReceiveHighest: UInt64; ReceiveOffset: UInt64; ReceiveLimit: UInt64; FinalSize: UInt64; FinalSizeKnown: Boolean; FinQueued: Boolean; FinSent: Boolean; FinAcknowledged: Boolean; StopSendingReceived: Boolean; StopError: UInt64; ResetError: UInt64; ReceiveError: UInt64; ReleasedReceiveCredit: UInt64; BufferedSendBytes: Integer; BufferedReceiveBytes: Integer;

classtQuicStreamManager

Calls require external serialization. Stream IDs are sparse: a high ID implicitly opens lower IDs of that type without allocating them. Only materialized records and sparse retired ranges consume MaxStreams. Explicit retirement requires both transport directions complete and an application release. Per-type retired floors and sparse ranges prevent reopening without retaining a record for every completed request. Resource exhaustion fails explicitly. Configure advertised credit together with budgets; a peer may use all granted credit.

MaxBufferedBytes bounds physical retained send allocations and receive bytes together. RetainedSendBytes charges the full backing array of each admission until its final fragment retires; Buffered* count logical bytes. Each direction has at most MaxRangesPerStream ranges. Replacement metadata and receive reassembly need at most an additional copy of their budgets. Buffers passed as const may be retained read-only; no alias may subsequently modify their elements. Copies provide independence wherever reassembly requires mutation. Returned arrays may be retained as shared read-only buffers.

Taking data or releasing TBytes references never grants network credit. ReleaseReceiveCredit records explicit consumption. IncreaseReceive* calls explicitly authorize new advertised maxima. The scheduler transmits and retransmits MAX_* and RESET_STREAM frames using the current state; this class does not send packets or run timers. MAX_STREAMS counts all opened streams, including terminated streams, and is never recycled implicitly.

constructor Create(aRole: tQuicRole; const aLocalLimits, aPeerLimits: tQuicStreamLimits; const aBudgets: tQuicStreamBudgets); destructor Destroy; override; procedure ApplyFreshLimits(const aLocal, aPeer: tQuicStreamLimits);
Authenticated fresh limits may raise remembered credit without changing stream offsets, reservations, delivery state or retained bytes.
procedure ConfigureSendWindow(aMaxBytes: Integer);
Optional retained-send policy, configured before queueing any data. Zero preserves the legacy shared-pool policy. Full description »
procedure PrepareSendWindow(aMaxBytes, aMaxRanges: Integer);
Opt-in preparation may raise the range budget before any local data was queued. A failed call preserves both settings; buffered peer input is allowed. Existing shared-pool users keep their configured budgets. The owner must prepare output intervals in the same step; see the memory/throughput rule on ConfigureSendWindow. No metadata is eagerly allocated by preparation.
function CanRetireStream(aStreamID: UInt64): Boolean;
Call only after the application has relinquished its stream references. Retirement never grants credit. Late peer frames for a retired ID are ignored, including conflicting final sizes, without reopening it.
function RetireStream(aStreamID: UInt64): Boolean; function IsRetiredStream(aStreamID: UInt64): Boolean; function PeerOpenedStreams(aUnidirectional: Boolean): UInt64; function PeerUnmaterializedStreams(aUnidirectional: Boolean): UInt64; function StreamRecordReservation: UInt64; property MetadataCount: Integer read GetMetadataCount; function MaxStreamRecords: Integer;
Returns the MaxStreams value, obtained via fBudgets.
function OpenStream(aUnidirectional: Boolean): UInt64; procedure ReceiveStream(aStreamID, aOffset: UInt64; const aData: TBytes; aFin: Boolean); overload; procedure ReceiveStream(aStreamID, aOffset: UInt64; const aData: TBytes; aFin, aEarly: Boolean); overload;
Provenance follows authenticated bytes, including ranges behind holes. Duplicate bytes already delivered never change an application's history.
procedure ReceiveReset(aStreamID, aError, aFinalSize: UInt64); procedure ReceiveStopSending(aStreamID, aError: UInt64); procedure ReceiveStreamDataBlocked(aStreamID: UInt64); procedure ReceiveMaxData(aLimit: UInt64); procedure ReceiveMaxStreamData(aStreamID, aLimit: UInt64); procedure ReceiveMaxStreams(aUnidirectional: Boolean; aLimit: UInt64); function QueueSend(aStreamID: UInt64; const aData: TBytes; aFin: Boolean): UInt64; overload;
Reserves peer credit and returns the first offset. The whole array and FIN succeed or fail together. Full description »
function QueueSend(aStreamID: UInt64; const aData: TBytes; aDataOffset, aCount: Integer; aFin: Boolean): UInt64; overload;
Admits the complete slice and FIN atomically, returning its first stream offset. May retain the complete read-only aData allocation; neither party may mutate its elements through aliases. Full description »
function CopySend(aStreamID, aOffset: UInt64; aMaxBytes: Integer; out aData: TBytes; out aFin: Boolean): Boolean;
Returns at most aMaxBytes at the exact stream offset, sharing a complete array or copying a partial slice for compatibility. Returned elements must remain read-only through all aliases. False explicitly empties both outputs. Empty FIN is valid. Does not change sent state or return credit.
function FindSendInfo(aStreamID, aAtOrAfter: UInt64; aMaxBytes: Integer; out aOffset: UInt64; out aCount: Integer; out aFin: Boolean): Boolean;
Describes the same first retained range as FindSend without copying data. Failure explicitly zeroes all scalar outputs.
function FindSend(aStreamID, aAtOrAfter: UInt64; aMaxBytes: Integer; out aOffset: UInt64; out aData: TBytes; out aFin: Boolean): Boolean;
Finds the next retained range or FIN, skipping acknowledged holes. Returns a whole read-only array, copying partial slices for compatibility. No alias may mutate returned elements. False explicitly clears every output.
function FindSendSlice(aStreamID, aAtOrAfter: UInt64; aMaxBytes: Integer; out aOffset: UInt64; out aData: TBytes; out aDataOffset, aCount: Integer; out aFin: Boolean): Boolean;
Finds the next retained range or FIN without copying payload. aData retains the backing array; only aDataOffset/aCount identify selected bytes. Neither party may modify shared elements through aliases. The result may outlive ACK/reset or this manager; caller-held references are outside its budget. Does not change sent state. False explicitly clears every output.
procedure MarkSent(aStreamID, aOffset, aLength: UInt64; aFin: Boolean); procedure AcknowledgeSend(aStreamID, aOffset, aLength: UInt64; aFin: Boolean);
Call only for STREAM ranges mapped from valid acknowledged sent packets. Duplicate/overlapping ACKs are harmless. Retires only acknowledged bytes and FIN by descriptor trimming/splitting, without copying retained data. Physical backing stays charged until its final fragment retires. A range budget failure leaves buffers and counters unchanged.
procedure ResetSend(aStreamID, aError: UInt64); procedure MarkResetSent(aStreamID: UInt64); procedure AcknowledgeReset(aStreamID: UInt64); function TakeReceived(aStreamID: UInt64; out aData: TBytes; out aFin: Boolean): Boolean; overload;
Delivers contiguous data once and optionally FIN. False explicitly empties both outputs. Reset notification is delivered once by ConsumeReset.
function TakeReceived(aStreamID: UInt64; out aData: TBytes; out aFin, aEarly: Boolean): Boolean; overload;
Returns one homogeneous provenance span. A differently attributed FIN follows in a separate empty chunk. All outputs are initialized on failure.
function StreamHasEarlyData(aStreamID: UInt64): Boolean; function ConsumeReset(aStreamID: UInt64; out aError: UInt64): Boolean; procedure ReleaseReceiveCredit(aStreamID, aCount: UInt64);
Releases at most delivered bytes not previously released. A reset permits release of its entire final size, including holes charged to MAX_DATA. This bookkeeping does not change any advertised maximum.
procedure IncreaseReceiveMaxData(aLimit: UInt64); procedure IncreaseReceiveMaxStreamData(aStreamID, aLimit: UInt64); procedure IncreaseReceiveMaxStreams(aUnidirectional: Boolean; aLimit: UInt64); function GetStreamInfo(aStreamID: UInt64; out aInfo: tQuicStreamInfo): Boolean;
Reports implicit lower streams without allocating metadata. False explicitly returns zero fields and absent states.
function StreamIDAt(aIndex: Integer; out aStreamID: UInt64): Boolean;
Enumerates live records in creation order, compacted on retirement, without opening implicit streams or changing state. Invalid indices return False and explicitly return zero. Calls require the manager's serialization.
procedure SetLookupKey(aKey: UInt64);
Keys the stream-ID lookup with an odd multiplier derived from aKey. Owners pass a random value so that a peer choosing stream IDs within its limits cannot force long probes; without a key a fixed default applies. Allowed only before the first record; afterwards raises eQuicError.
function FindStreamIndex(aStreamID: UInt64; out aIndex: Integer): Boolean;
Creation index (the StreamIDAt index) of a retained record, in expected constant time, without opening or materializing a stream. False explicitly returns -1.
function TakeServiceStream(out aStreamID: UInt64; out aIndex: Integer): Boolean;
Service hints. A stream is queued, at most once at a time and in FIFO order, when a STREAM frame leaves data or FIN deliverable at its read cursor, when a locally initiated stream receives its first peer input, when a reset becomes undelivered, and on the first STOP_SENDING. Full description »
function RequestService(aStreamID: UInt64): Boolean;
Queues a retained record at the back unless it is already queued, for a consumer whose visit was interrupted. False for absent or implicitly opened IDs, which are not materialized. Never allocates or raises.
function SendCapacity(aStreamID: UInt64): Integer;
Maximum bytes QueueSend can admit now, including flow-control, shared buffer and retained-range budgets. Zero also covers absent/closed sends. The lookup does not materialize implicit stream records.
function CanOpenStream(aUnidirectional: Boolean): Boolean;
Reports temporary peer stream-count blockage only. OpenStream still enforces the configured metadata budget and raises on exhaustion.
property LocalLimits: tQuicStreamLimits read fLocalLimits; property PeerLimits: tQuicStreamLimits read fPeerLimits; property ReceivedDataCount: UInt64 read fReceivedData; property SentDataCount: UInt64 read fQueuedData;
Queued offsets reserve credit permanently, including data later reset. Acknowledgement retires storage and does not restore peer credit.
property ReleasedReceiveCredit: UInt64 read fReleasedReceiveCredit; property MaxSendBytes: Integer read fMaxSendBytes; property SendBufferCapacity: Integer read GetSendBufferCapacity; property RetainedBytes: Integer read GetRetainedBytes;
Physical backing charged by this manager, including receive bytes. Published output references retained by callers have independent lifetimes.
property RetainedSendBytes: Integer read fRetainedSendBytes;
Full send-allocation charges, released after their last fragment retires. Separate admissions of one array can conservatively charge it again.
property BufferedBytes: Integer read fBufferedBytes;
Logical unacknowledged send bytes plus retained receive bytes.
property BufferedSendBytes: Integer read fBufferedSendBytes;
Logical unacknowledged send bytes; physical admission uses RetainedSendBytes.
property BufferedReceiveBytes: Integer read fBufferedReceiveBytes; property MaxReceiveRanges: Integer read fMaxReceiveRanges;
Diagnostics: the cap on receive pieces per stream and connection-wide, the live connection-wide count of receive pieces, and the cumulative bytes moved while reassembling received data. The last stays linear in the bytes buffered on an amortized insert path and climbs toward their square on a merge-and-copy one.
property MaxReceiveRangesTotal: Integer read fMaxReceiveRangesTotal; property ReceiveRangeCount: Integer read fReceiveRangeCount; property ReceiveBytesCopied: Int64 read fReceiveBytesCopied; property StreamCount: Integer read GetStreamCount; property ServicePending: Boolean read GetServicePending;
True while at least one service hint is queued.

Types (enumerations, sets, aliases)

enumtQuicStreamSendState

  tQuicStreamSendState = (qssAbsent, qssReady, qssSending, qssDataSent,
    qssDataAcknowledged, qssResetQueued, qssResetSent, qssResetAcknowledged);

enumtQuicStreamReceiveState

  tQuicStreamReceiveState = (qrsAbsent, qrsReceiving, qrsSizeKnown,
    qrsDataReceived, qrsDataRead, qrsResetReceived, qrsResetRead);

Routines