Atom

net.connect()

Connects a TCP or UDP socket.

Signature

net.connect(host, port[, options])

Parameters

Nonempty hostname/address string, signed port from 0 through 65535, and optional settings above.

Returns

Connected socket.

Behavior

Resolves the name, connects, and completes any configured TLS handshake before returning.

Errors

DNS, connection, TLS or timeout error.

Example

Atom
use net
s = net.bind('127.0.0.1', 0, {timeout = 2})
c = net.connect('127.0.0.1', net.local(s).port, {protocol = 'udp', timeout = 2})
net.close(c)
net.close(s)