Skip to main content

Function: connect()

Call Signature​

connect(transport, host, port, options?): Promise<TCPSocket>

Creates a connection to the target host + port over the selected transport. Returns the appropriate Direct Sockets object.

Parameters​

transport​

"tcp"

Type of transport for the connection.

host​

string

Hostname for the connection. Basic lookup using lookup will be performed.

port​

number

Destination port (where applicable).

options?​

ConnectOptions

Extra connection options.

Returns​

Promise<TCPSocket>

Call Signature​

connect(transport, host, port, options?): Promise<TLSSocket>

Creates a connection to the target host + port over the selected transport. Returns the appropriate Direct Sockets object.

Parameters​

transport​

"tls"

Type of transport for the connection.

host​

string

Hostname for the connection. Basic lookup using lookup will be performed.

port​

number

Destination port (where applicable).

options?​

TLSConnectOptions

Extra connection options.

Returns​

Promise<TLSSocket>

Call Signature​

connect(transport, host): Promise<PipeSocket>

Creates a connection to the target host + port over the selected transport. Returns the appropriate Direct Sockets object.

Parameters​

transport​

"pipe"

Type of transport for the connection.

host​

string

Hostname for the connection. Basic lookup using lookup will be performed.

Returns​

Promise<PipeSocket>

Call Signature​

connect(transport, host, port, options?): Promise<UDPSocket>

Creates a connection to the target host + port over the selected transport. Returns the appropriate Direct Sockets object.

Parameters​

transport​

"udp"

Type of transport for the connection.

host​

string

Hostname for the connection. Basic lookup using lookup will be performed.

port​

number

Destination port (where applicable).

options?​

ConnectOptions

Extra connection options.

Returns​

Promise<UDPSocket>