createConnection - Node documentation
function createConnection

Usage

import { createConnection } from "node:net";

A factory function, which creates a new Socket, immediately initiates connection with socket.connect(), then returns the net.Socket that starts the connection.

When the connection is established, a 'connect' event will be emitted on the returned socket. The last parameter connectListener, if supplied, will be added as a listener for the 'connect' event once.

Possible signatures:

The connect function is an alias to this function.

Parameters

options: NetConnectOpts
optional
connectionListener: () => void

Return Type

Parameters

port: number
optional
host: string
optional
connectionListener: () => void

Return Type

Parameters

path: string
optional
connectionListener: () => void

Return Type