demo · v131
Direct Sockets API
TCPSocket and UDPSocket from JavaScript - bypassing the HTTP layer entirely. Restricted to secure Isolated Web Apps with the direct-sockets permissions-policy gate. This page probes the origin, policy, and constructors before trying to open a connection so you can see which precondition failed.
scope
Outside an Isolated Web App these constructors are either undefined or throw on
open(). The probe + try-it buttons below show exactly what your browser exposes here.
precondition gates
error-name map
| error | likely gate | what to check next |
|---|---|---|
ReferenceError / constructor undefined | API not exposed | Check Chrome version, flag state, IWA install state, and isolated-app: origin. |
SecurityError | Origin or isolation gate | Check secure context, cross-origin isolation, IWA scheme, and manifest permissions. |
NotAllowedError | Permissions-policy gate | Check direct-sockets, local/loopback/private network policy, and enterprise/user policy. |
NetworkError / AbortError | Endpoint or transport failure | Check DNS, port reachability, firewall, private-network target gates, and protocol handshake. |
try it
the api
const tcp = new TCPSocket("example.com", 443);
const { readable, writable } = await tcp.opened;
// stream bytes either way
const w = writable.getWriter();
await w.write(new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n"));