Skip to content

CONCEPT Cited by 1 source

Inbound TCP socket handler

A runtime handler that accepts an inbound TCP connection as a ReadableStream/WritableStream pair, enabling serverless compute to serve arbitrary TCP-based protocols (gRPC, custom binary protocols, game servers, database wire protocols) without being limited to HTTP request/response semantics.

Definition

The connect(socket) handler is the TCP-altitude equivalent of the fetch(request) handler for HTTP. Where fetch() receives a Request object and returns a Response, connect() receives a bidirectional Socket and can read/write indefinitely — enabling persistent connections, full-duplex streaming, and protocol-agnostic handling.

Key properties

  • Protocol-agnostic: the handler sees raw bytes; any TCP protocol works (gRPC, MQTT, Redis wire protocol, custom binary)
  • Composable routing: the socket can be forwarded through a chain — Worker → Worker, Worker → Durable Object, Durable Object → Container
  • Stream-based API: uses standard Web Streams (socket.readable, socket.writable) so existing stream-processing patterns apply
  • Ingress-dependent: requires an L4 ingress proxy (e.g. Spectrum) to route the raw TCP connection to the handler

Seen in

Last updated · 608 distilled / 1,858 read