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.
Implements
Section titled “Implements”Transport
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DuplexTransport(
stream):DuplexTransport
Defined in: net-transport-node/src/duplex-transport.ts:45
Parameters
Section titled “Parameters”stream
Section titled “stream”Duplex
The already-connected duplex stream to carry frames over. Connection setup is deliberately not this class’s concern.
Returns
Section titled “Returns”DuplexTransport
Properties
Section titled “Properties”
readonlymode:TransportMode="stream"
Defined in: net-transport-node/src/duplex-transport.ts:23
Whether bytes arrive as a stream or as discrete messages.
Implementation of
Section titled “Implementation of”Transport.mode
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy(
error?):void
Defined in: net-transport-node/src/duplex-transport.ts:196
Tear the transport down immediately, discarding pending I/O.
Parameters
Section titled “Parameters”error?
Section titled “error?”Error
Optional cause, propagated to TransportHandlers.error where the transport supports it.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.destroy
end():
Promise<void>
Defined in: net-transport-node/src/duplex-transport.ts:184
Half-close the outbound direction and resolve once flushed.
Returns
Section titled “Returns”Promise<void>
Resolves when all pending writes have been sent.
Implementation of
Section titled “Implementation of”Transport.end
pause()
Section titled “pause()”pause():
void
Defined in: net-transport-node/src/duplex-transport.ts:176
Stop delivering TransportHandlers[“data”] until resume.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.pause
resume()
Section titled “resume()”resume():
void
Defined in: net-transport-node/src/duplex-transport.ts:180
Resume delivery suspended by pause.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.resume
setWriteCoalescing()
Section titled “setWriteCoalescing()”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.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.setWriteCoalescing
start()
Section titled “start()”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.
Parameters
Section titled “Parameters”handlers
Section titled “handlers”TransportHandlers
Callbacks to receive data and lifecycle notifications.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.start
stop()
Section titled “stop()”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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Transport.stop
write()
Section titled “write()”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.
Parameters
Section titled “Parameters”buffers
Section titled “buffers”readonly Buffer<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.
Implementation of
Section titled “Implementation of”Transport.write