Transport
Defined in: packages/net-core/src/transport.ts:56
Abstraction over anything that can carry framed bytes.
Must not assume a Duplex. HTTP/3 runs over QUIC streams, DNS runs over UDP
datagrams, and DNS-over-HTTPS runs over the body of another session — none of
which are sockets, and all of which reuse the same codecs and correlation
logic.
Kept as a bespoke contract rather than a bare ReadableStream/
WritableStream pair. Collapsing to Web Streams costs ~112 ns per received
chunk (negligible) but forces either a per-value concatenation (16-233x
slower, measured) or the loss of writev batching (3.9x more syscalls,
measured) on the send side — and a codec is a symmetric pair that should not
need two plumbing vocabularies to follow one round trip.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”
readonlymode:TransportMode
Defined in: packages/net-core/src/transport.ts:58
Whether bytes arrive as a stream or as discrete messages.
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy(
error?):void
Defined in: packages/net-core/src/transport.ts:113
Tear the transport down immediately, discarding pending I/O.
Parameters
Section titled “Parameters”error?
Section titled “error?”unknown
Optional cause, propagated to TransportHandlers.error where the transport supports it.
Returns
Section titled “Returns”void
end():
Promise<void>
Defined in: packages/net-core/src/transport.ts:105
Half-close the outbound direction and resolve once flushed.
Returns
Section titled “Returns”Promise<void>
Resolves when all pending writes have been sent.
pause()
Section titled “pause()”pause():
void
Defined in: packages/net-core/src/transport.ts:95
Stop delivering [“data”] until resume.
Returns
Section titled “Returns”void
resume()
Section titled “resume()”resume():
void
Defined in: packages/net-core/src/transport.ts:98
Resume delivery suspended by pause.
Returns
Section titled “Returns”void
setWriteCoalescing()?
Section titled “setWriteCoalescing()?”
optionalsetWriteCoalescing(enabled):void
Defined in: packages/net-core/src/transport.ts:123
Whether a small write may be held back briefly so it leaves together with later ones — Nagle’s algorithm on TCP. A protocol whose exchanges wait on small messages turns it off; a bulk transfer gains nothing from either.
Omitted by transports that never hold writes back (datagrams, a stream multiplexed over another connection), where there is nothing to turn off.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
start()
Section titled “start()”start(
handlers):void
Defined in: packages/net-core/src/transport.ts:67
Begin delivering data to handlers.
Called once by the FrameLink that owns this transport.
Parameters
Section titled “Parameters”handlers
Section titled “handlers”Callbacks to receive data and lifecycle notifications.
Returns
Section titled “Returns”void
stop()
Section titled “stop()”stop():
void
Defined in: packages/net-core/src/transport.ts:76
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.
Returns
Section titled “Returns”void
write()
Section titled “write()”write(
buffers,signal?):Promise<void>
Defined in: packages/net-core/src/transport.ts:92
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.
Parameters
Section titled “Parameters”buffers
Section titled “buffers”readonly Uint8Array<ArrayBufferLike>[]
Ordered payload fragments.
signal?
Section titled “signal?”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.
Returns
Section titled “Returns”Promise<void>
Resolves once the transport has accepted the bytes and any backpressure has cleared.