LineSocket

Methods
7
Fields
None

Getting one

LineSocket.connect(…)

Methods

MethodReturnsDescription
send(string)()Send line with \r\n appended (queued until connected). A closed socket is SocketException; a line holding CR or LF is refused.
close()()Close it: isClosed() is true at once, and onClose(socket, nil) follows at the next invoke point. Closing a closed socket does nothing.
isConnected()booleanWhether it was connected: still true after it closed.
isClosed()booleanWhether it is closed (by close(), the peer or an error).
getHost()stringThe host it was opened to.
getPort()numberThe remote port, or 0 until it is connected.
connect(string, number, boolean, any)LineSocketOpen a line-by-line connection to host:port (TLS when tls), through the account's proxy. listener is a table whose `onConnect(socket)…

Returned by

MethodReturnsDescription
LineSocketClass.connectLineSocketOpen a line-by-line connection to host:port (TLS when tls), through the account's proxy. listener is a table whose `onConnect(socket)…

Method details

send

send: (LineSocket, string) -> ()

Send line with \r\n appended (queued until connected). A closed socket is SocketException; a line holding CR or LF is refused.

close

close: (LineSocket) -> ()

Close it: isClosed() is true at once, and onClose(socket, nil) follows at the next invoke point. Closing a closed socket does nothing.

isClosed

isClosed: (LineSocket) -> boolean

Whether it is closed (by close(), the peer or an error).

connect

connect: (string, number, boolean, any) -> LineSocket

Open a line-by-line connection to host:port (TLS when tls), through the account's proxy. listener is a table whose onConnect(socket), onLine(socket, line) and onClose(socket, reason) run on the client thread (reason nil for a normal close, else the exception text). A marketplace plugin reaches no host: its connection is refused before anything is sent.