UDPSocket class

Represents a single UDX connection, managed by a UDXMultiplexer.

This class handles the logic for a single connection, including stream management, flow control, and packet processing, but delegates the actual network I/O to the multiplexer.

Mixed-in types

Constructors

UDPSocket.new({required UDX udx, required UDXMultiplexer multiplexer, required InternetAddress remoteAddress, required int remotePort, required ConnectionCids cids})
Creates a new UDX connection socket.

Properties

busy bool
Whether the socket is busy (has active streams).
no setter
cids ConnectionCids
The Connection IDs for this connection.
getter/setter pair
closing bool
Whether the socket is closing.
no setter
handshakeComplete Future<void>
A future that completes when the handshake is successful.
no setter
hashCode int
The hash code for this object.
no setterinherited
idle bool
Whether the socket is idle (no active streams).
no setter
multiplexer UDXMultiplexer
The multiplexer that owns this socket.
getter/setter pair
remoteAddress InternetAddress
The remote address of the peer.
getter/setter pair
remotePort int
The remote port of the peer.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
udx UDX
The UDX instance that created this socket.
final

Methods

address() Map<String, dynamic>?
Returns the remote peer's address.
advertiseConnectionWindowUpdate() → void
Called when the application has processed data.
canCreateNewStream() bool
Checks if a new outgoing stream can be created.
close() Future<void>
Closes the connection.
override
decrementConnectionBytesSent(int bytes) → void
Called by UDXStream when data is acknowledged.
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
flushStreamBuffer() → void
Flushes buffered streams that were received before a listener was attached. This ensures that listeners attached after stream creation still receive the stream event.
getAvailableConnectionSendWindow() int
Gets the available send window at the connection level.
getRecvBufferSize() int
Gets the receive buffer size.
getRegisteredStreamsCount() int
getSendBufferSize() int
Gets the send buffer size.
getStreamBuffer() List<UDXStream>
handleIncomingDatagram(Uint8List data, InternetAddress fromAddress, int fromPort) → void
Processes an incoming datagram from the multiplexer.
incrementConnectionBytesSent(int bytes) → void
Called by UDXStream when it sends data.
incrementOutgoingStreams() → void
Call this when a new outgoing stream is created.
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
onStreamDataProcessed(int bytesProcessed) → void
Called by UDXStream when it has received and processed data.
popInitialPacket(int streamId) Uint8List?
Retrieves and removes the initial buffered packet for a stream.
registerStream(UDXStream stream) → void
Registers a UDXStream with this socket.
send(Uint8List data) → void
Sends data to the peer via the multiplexer.
sendMaxDataFrame(int localMaxData, {int streamId = 0}) Future<void>
Sends a MAX_DATA frame to the peer.
sendMaxStreamsFrame() Future<void>
setLocalMaxStreamsForTest(int value) → void
setRecvBufferSize(int size) → void
Sets the receive buffer size.
setRemoteMaxStreamsForTest(int value) → void
setSendBufferSize(int size) → void
Sets the send buffer size.
setTTL(int ttl) → void
Sets the TTL (Time To Live) for outgoing packets. (Not implemented)
toString() String
A string representation of this object.
inherited
unregisterStream(int streamId) → void
Unregisters a UDXStream from this socket.

Operators

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

Constants

defaultInitialConnectionWindow → const int
Default initial connection-level flow control window (e.g., 1MB).
defaultMaxStreams → const int
Default maximum number of concurrent streams.