Skip to content

DatagramTransport

Defined in: net-transport-node/src/datagram-transport.ts:32

Message-mode Transport over a UDP socket.

Each datagram is delivered as exactly one complete frame: bytes are never carried across deliveries, so a decoder returning incomplete means the message was truncated rather than that more is coming. That distinction is why TransportMode is part of the transport contract — DNS over UDP and DNS over TCP share a codec but must not share buffering behaviour.

Correlation is the caller’s problem, and cannot be positional: pair this with a KeyedRegistry over the protocol’s transaction identifier.

  • Transport

new DatagramTransport(socket, options?): DatagramTransport

Defined in: net-transport-node/src/datagram-transport.ts:43

Socket

DatagramTransportOptions

DatagramTransport

readonly mode: TransportMode = "message"

Defined in: net-transport-node/src/datagram-transport.ts:33

Whether bytes arrive as a stream or as discrete messages.

Transport.mode

destroy(): void

Defined in: net-transport-node/src/datagram-transport.ts:140

Tear the transport down immediately, discarding pending I/O.

void

Transport.destroy


end(): Promise<void>

Defined in: net-transport-node/src/datagram-transport.ts:136

Half-close the outbound direction and resolve once flushed.

Promise<void>

Resolves when all pending writes have been sent.

Transport.end


pause(): void

Defined in: net-transport-node/src/datagram-transport.ts:123

Stop delivering TransportHandlers[“data”] until resume.

void

Transport.pause


resume(): void

Defined in: net-transport-node/src/datagram-transport.ts:127

Resume delivery suspended by pause.

void

Transport.resume


start(handlers): void

Defined in: net-transport-node/src/datagram-transport.ts:50

Begin delivering data to handlers.

Called once by the FrameLink that owns this transport.

TransportHandlers

Callbacks to receive data and lifecycle notifications.

void

Transport.start


stop(): void

Defined in: net-transport-node/src/datagram-transport.ts:70

Detach the installed handlers without closing the transport.

Used when handing an already-connected transport to another consumer, as in an HTTP Upgrade. Contrast with destroy, which tears the transport down.

void

Transport.stop


write(buffers, signal?): Promise<void>

Defined in: net-transport-node/src/datagram-transport.ts:86

Write buffers as a single logical unit and resolve once accepted.

Fragments are written in order and, where the transport supports it, coalesced into one vectored write. In message mode the buffers form exactly one outbound message.

readonly Buffer<ArrayBufferLike>[]

Ordered payload fragments.

AbortSignal

Cancels the wait for capacity. Note that bytes already handed to the transport cannot be unsent; aborting rejects the caller but does not retract the write.

Promise<void>

Resolves once the transport has accepted the bytes and any backpressure has cleared.

Transport.write