demo · v131

TCPServerSocket: listen on a local port

An IWA can listen for incoming TCP connections via TCPServerSocket. The classic use is a local control panel for hardware (printer queue managers, lab instruments, kiosk daemons) where the web app is itself the server. This page wires up the listener and renders each connection as a tile.

flags + scheme TCPServerSocket is IWA-only with the direct-sockets permission. On a regular origin the constructor is missing — the page degrades gracefully.
idle

connections

no clients yet

server log

the api

const server = new TCPServerSocket("0.0.0.0", { localPort: 9100 });
const { readable } = await server.opened;
const reader = readable.getReader();
while (true) {
  const { value: conn, done } = await reader.read();
  if (done) break;
  handleConnection(conn);
}

async function handleConnection(sock) {
  const { readable, writable } = await sock.opened;
  // ... echo loop ...
}

see also