Class: Connection

models/Connection~ Connection


new Connection(options)

Parameters:
Name Type Description
options

Required options to initialize the TCP connection

Properties
Name Type Description
name

The unique name of the connection

host

The hostname (ie. 192.168.1.101)

port

The port for the connection (ie. 3000)

Source:
Throws:

If one of the parameters weren't provided

Type
Error

Members


closed :boolean

Whether the connection has been closed

Type:
  • boolean
Source:

socket :net.Socket

A reference to the socket.

Type:
  • net.Socket
Source:

timeout :number

Timeout for the socket in milliseconds. Defaults to 5 seconds

Type:
  • number
Source:

Methods


connect()

Attempts to connect to the TCP socket

Source:

disconnect()

Disconnects from the TCP socket

Source:

reconnect()

Reconnects to the socket (same as doing a disconnect and then a connect)

Source:

write(data)

Attempts to send data through the socket

Parameters:
Name Type Description
data Object

The data to send

Source:
Fires:
  • Connection:write