Skip to content

createTcpConnector

createTcpConnector(options?): Connector

Defined in: net-transport-node/src/connect-tcp.ts:57

A Connector over TCP: cleartext for a target with secure unset, TLS with SNI and the target’s ALPN protocols otherwise. Resolves once the TLS handshake completed, with the protocol ALPN chose.

The socket allows half-open connections, like the ones TcpListener accepts: the local side closes only when its transport is ended or destroyed.

TcpConnectorOptions

Connector

const connect = createTcpConnector({ tls: { ca: myRootCertificate } });
const { transport, alpnProtocol } = await connect({
host: "localhost",
port: 8443,
secure: true,
alpnProtocols: ["h2"],
});
```;