Skip to main content
createConnection - node__net.d.ts - Node documentation
function createConnection

Usage in Deno

```typescript import { createConnection } from "node:node__net.d.ts"; ```
createConnection(
options: NetConnectOpts,
connectionListener?: () => void,
): Socket
A factory function, which creates a new [Socket](../.././node__net.d.ts/~/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: * [createConnection](../.././node__net.d.ts/~/createConnection) * [createConnection](../.././node__net.d.ts/~/createConnection) for `IPC` connections. * [createConnection](../.././node__net.d.ts/~/createConnection) for TCP connections. The [connect](../.././node__net.d.ts/~/connect) function is an alias to this function.

Parameters

options: NetConnectOpts
optional
connectionListener: () => void

Return Type

createConnection(
port: number,
host?: string,
connectionListener?: () => void,
): Socket

Parameters

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

Return Type

createConnection(
path: string,
connectionListener?: () => void,
): Socket

Parameters

path: string
optional
connectionListener: () => void

Return Type