UDXStream class

A reliable, ordered stream over UDP.

With per-connection sequencing (QUIC RFC 9000), the stream no longer owns packet sequencing, congestion control, or receive ordering. Those are handled by the parent UDPSocket. The stream is a thin layer that:

Implemented types
Mixed-in types

Constructors

UDXStream(UDX udx, int id, {StreamType streamType = StreamType.bidirectional, bool framed = false, int initialSeq = 0, bool firewall(UDPSocket socket, int port, String host)?, int? initialCwnd, bool isInitiator = false})
Creates a new UDX stream

Properties

ack → Stream<int>
no setter
bytesRead ↔ int
Total bytes read from the stream
getter/setter pair
bytesWritten ↔ int
Total bytes written to the stream
getter/setter pair
closeEvents → Stream<void>
no setter
connected → bool
Whether the stream is connected
no setter
connectedAt ↔ DateTime?
Timestamp when the stream connected
getter/setter pair
cwnd → int
The congestion window (from connection-level CC)
no setter
data → Stream<Uint8List>
Data received on this stream.
no setter
done → Future<void>
Return a future which is completed when the StreamSink is finished.
no setteroverride
drain → Stream<void>
no setter
end → Stream<void>
no setter
firewall → bool Function(UDPSocket socket, int port, String host)?
The firewall function
final
framed → bool
Whether the stream is in framed mode
final
hashCode → int
The hash code for this object.
no setterinherited
id → int
The stream ID
final
inflight → int
The number of bytes in flight (from connection-level CC)
no setter
initialSeq → int
The initial sequence number (kept for API compatibility but not used for per-stream ordering)
final
isInitiator → bool
Whether this stream was created by this endpoint.
final
maxRetransmissionAttempts ↔ int
Maximum number of retransmission attempts before considering packet lost
getter/setter pair
message → Stream<Uint8List>
no setter
mtu → int
The maximum transmission unit (MTU)
no setter
packetTimeoutTolerance ↔ int
Total timeout tolerance for packet-level operations (in seconds)
getter/setter pair
priority ↔ int
Priority for this stream (0-255, lower value = higher priority)
getter/setter pair
receiveWindow → int
The local receive window size, in bytes. Auto-tuned upward for streams that actually move bulk data, capped at _maxReceiveWindow.
no setter
remoteFamily ↔ int?
The remote address family
getter/setter pair
remoteHost ↔ String?
The remote host
getter/setter pair
remoteId ↔ int?
The remote stream ID
getter/setter pair
remotePort ↔ int?
The remote port
getter/setter pair
remoteReceiveWindow → int
The remote peer's receive window size
no setter
rtt → Duration
The round-trip time (from connection-level CC)
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
send → Stream<Uint8List>
no setter
streamType → StreamType
The type/directionality of this stream
final
udx → UDX
The UDX instance that created this stream
final

Methods

add(Uint8List data) → Future<void>
Adds a data event to the sink.
override
addError(Object error, [StackTrace? stackTrace]) → void
Adds an error to the sink.
override
addStream(Stream<Uint8List> stream) → Future<void>
Consumes the elements of stream.
override
close() → Future<void>
Tells the stream sink that no further streams will be added.
override
closeWrite() → Future<void>
connect(UDPSocket socket, int remoteId, int port, String host) → Future<void>
Connects the stream to a remote endpoint
deliverData(int offset, Uint8List data) → void
Delivers a chunk at its offset in the stream, releasing whatever has become contiguous.
deliverFin(int finalSize) → void
Records where the stream ends. finalSize is the offset one past the peer's last byte.
deliverReset(int errorCode) → void
Delivers RESET from the socket.
deliverStopSending(int errorCode) → void
Delivers STOP_SENDING from the socket.
deliverStreamDataBlocked() → void
The peer is out of send credit (STREAM_DATA_BLOCKED). Re-advertise the current limit without growing the window, as go-udx does. WINDOW_UPDATE is never retransmitted, so this is what repairs a stream whose update was lost; not growing the window means a peer can't inflate our receive buffer just by claiming to be blocked.
deliverWindowUpdate(int windowSize) → void
Delivers WINDOW_UPDATE from the socket.
emit(String event, [dynamic data]) → void
Emits an event of the given type with the given data
inherited
flushBufferedStreams(String event, UDXEventCallback callback, List buffer) → void
Flushes buffered events for a specific event type to a new listener.
inherited
internalHandleSocketEvent(dynamic event) → void
Handles an incoming socket event (datagram). This is kept for backward compatibility but the socket now handles connection-level sequencing and calls deliverData/deliverFin/deliverReset directly.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on(String event) → Stream<UDXEvent>
Returns a stream of events for the given type
inherited
reset(int errorCode) → Future<void>
setPriority(int newPriority) → void
setSocketForTest(UDPSocket? socket) → void
Sets the internal socket. For testing purposes only.
setWindow(int newSize) → void
Sets the receive window size and re-advertises.
stopReceiving(int errorCode) → Future<void>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

createIncoming(UDX udx, UDPSocket socket, int localId, int remoteId, String host, int port, {required ConnectionId destinationCid, required ConnectionId sourceCid, bool framed = false, int initialSeq = 0, int? initialCwnd, bool firewall(UDPSocket socket, int port, String host)?, StreamType streamType = StreamType.bidirectional}) → UDXStream
createOutgoing(UDX udx, UDPSocket socket, int localId, int remoteId, String host, int port, {StreamType streamType = StreamType.bidirectional, bool framed = false, int initialSeq = 0, int? initialCwnd, bool firewall(UDPSocket socket, int port, String host)?}) → Future<UDXStream>
getMaxPayloadSizeTestHook() → int