Skip to content

socket: members

21 implemented, 0 reserved. Entries are sorted by name.

socket.address: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

The host given to connect.

echo(temp.s.address);

Specification: web-and-files.md§8.4.

socket.bind(port: number, udp: number) -> number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Listens on a port (or receives datagrams when the second argument is true). Only ports of Server Options socketbindports are allowed, on the loopback unless socketbindpublic is true. onBind or onBindFailed fires.

temp.s = new TSocket("Srv"); temp.s.bind(8082, false);

Specification: web-and-files.md§8.9.

socket.clients: array

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

On a listening TSocket: the array of accepted connections still alive.

echo(this.clients.size());

Specification: web-and-files.md§8.9.

socket.close()

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Closes the connection, or cancels one that is opening.

temp.s.close();

Specification: web-and-files.md§8.3.

socket.connect(host: string, port: number) -> number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Starts a TCP connection to a host and port and returns at once. The host must be in Server Options httpallowlist. onConnect or onConnectFailed fires later.

temp.s = new TSocket(); temp.s.connect("example.com", 7000);

Specification: web-and-files.md§8.3.

socket.data: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Bytes received and not yet cut into packages. Clear it when you have used it.

echo(temp.s.data);

Specification: web-and-files.md§8.4.

socket.enablessl: number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Set to true before connect to encrypt the connection with TLS 1.3. The certificate and the host name are always checked.

temp.s.enablessl = true;

Specification: web-and-files.md§8.8.

socket.error: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

The reason of the last failure.

echo(temp.s.error);

Specification: web-and-files.md§8.4.

socket.ipaddress: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

The address of the other side; empty until connected.

echo(temp.s.ipaddress);

Specification: web-and-files.md§8.4.

socket.isconnected: number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

Is 1 while the connection is open.

echo(temp.s.isconnected);

Specification: web-and-files.md§8.4.

socket.outdatalength: number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

Bytes queued by send that are not written yet.

echo(temp.s.outdatalength);

Specification: web-and-files.md§8.4.

socket.packagedelimiter: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

When set, incoming data is cut at this text and onReceiveDataPackage fires for each package.

echo(temp.s.packagedelimiter);

Specification: web-and-files.md§8.4.

socket.parent: object

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

On an accepted connection: the listening TSocket it came from.

echo(this.parent.port);

Specification: web-and-files.md§8.9.

socket.port: number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no. read-only.

The port given to connect.

echo(temp.s.port);

Specification: web-and-files.md§8.4.

socket.send(data: string) -> number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Queues bytes to be written to the connection; at most 1 MiB may wait.

temp.s.send("hello\n");

Specification: web-and-files.md§8.3.

socket.sendudp(data: string, host: string, port: number) -> number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Sends one datagram of at most 8192 bytes from a UDP socket. The host must be an address listed in httpallowlist.

temp.s.sendudp("ping", "127.0.0.1", 9000);

Specification: web-and-files.md§8.9.

socket.sslcertfile: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Client certificate for a TLS connection: a path of the form ssl/ inside the server’s data folder (PEM). Used with sslkeyfile before connect.

echo(temp.s.sslcertfile);

Specification: web-and-files.md§8.8.

socket.sslcipherlist: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Stored but not used: scripts cannot read key files and the engine fixes the protocol and cipher list.

echo(temp.s.sslcipherlist);

Specification: web-and-files.md§8.8.

socket.sslkeyfile: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Private key for the client certificate: a path of the form ssl/ inside the server’s data folder (PEM). The file is read by the engine and never by scripts.

echo(temp.s.sslkeyfile);

Specification: web-and-files.md§8.8.

socket.sslprotocol: string

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Stored but not used: scripts cannot read key files and the engine fixes the protocol and cipher list.

echo(temp.s.sslprotocol);

Specification: web-and-files.md§8.8.

socket.sslverifycert: number

Runs on: server and client. Origin: compatibility. Since: M14. Playground: no.

Always 1: the certificate of the server is always verified, writing false has no effect.

echo(temp.s.sslverifycert);

Specification: web-and-files.md§8.8.

Engine version 0.1.0. Built 2026-11-18.