TCP Server Connection
The TCP Server Connection class represents an active connection to a TCP server.
import TCPConnection from "embedded:io/tcp-server-connection";Constructor
Section titled “Constructor”TCPConnection(server, from)
Section titled “TCPConnection(server, from)”Creates a new TCP server connection instance.
TCPConnection(server, from)Parameters
Section titled “Parameters”server - The parent TCP server instance.
from - The client address information.
Instance Methods
Section titled “Instance Methods”close()
Section titled “close()”Closes the TCP connection.
close()read(count)
Section titled “read(count)”Reads data from the TCP connection.
read(count)Parameters
Section titled “Parameters”count - The number of bytes to read.
Return Value
Section titled “Return Value”A Buffer containing the read data.
write(data[, options])
Section titled “write(data[, options])”Writes data to the TCP connection.
write(data, options)Parameters
Section titled “Parameters”data - The data to write.
options (optional) - Write options.
#tcpError(error)
Section titled “#tcpError(error)”A method that is called when an error occurs on the connection.
tcpError(error)Parameters
Section titled “Parameters”error - An Error object describing the error.
#tcpReadable(count)
Section titled “#tcpReadable(count)”A method that is called when data is available to read.
tcpReadable(count)Parameters
Section titled “Parameters”count - The number of bytes available to read.
#tcpWritable(count)
Section titled “#tcpWritable(count)”A method that is called when the connection is ready for writing.
tcpWritable(count)Parameters
Section titled “Parameters”count - The number of bytes that can be written.