Skip to content

DuplexTransport

Defined in: net-transport-node/src/duplex-transport.ts:22

Transport over any Node duplex stream.

Covers TCP, TLS, Unix domain sockets, child-process pipes, and in-memory streams used by tests. Instances of StreamSocket and its subclasses expose a suitable stream through their stream accessor.

Writes are corked around the whole buffer list so a multi-fragment frame reaches the socket as one vectored write rather than one syscall per fragment.

  • Transport

new DuplexTransport(stream): DuplexTransport

Defined in: net-transport-node/src/duplex-transport.ts:45

Duplex

The already-connected duplex stream to carry frames over. Connection setup is deliberately not this class’s concern.

DuplexTransport

readonly mode: TransportMode = "stream"

Defined in: net-transport-node/src/duplex-transport.ts:23

Whether bytes arrive as a stream or as discrete messages.

Transport.mode

destroy(error?): void

Defined in: net-transport-node/src/duplex-transport.ts:196

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

Error

Optional cause, propagated to TransportHandlers.error where the transport supports it.

void

Transport.destroy


end(): Promise<void>

Defined in: net-transport-node/src/duplex-transport.ts:184

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/duplex-transport.ts:176

Stop delivering TransportHandlers[“data”] until resume.

void

Transport.pause


resume(): void

Defined in: net-transport-node/src/duplex-transport.ts:180

Resume delivery suspended by pause.

void

Transport.resume


setWriteCoalescing(enabled): void

Defined in: net-transport-node/src/duplex-transport.ts:207

Nagle’s algorithm on a TCP or TLS socket; nothing on any other stream, which never holds writes back.

boolean

void

Transport.setWriteCoalescing


start(handlers): void

Defined in: net-transport-node/src/duplex-transport.ts:47

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/duplex-transport.ts:64

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/duplex-transport.ts:84

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