Expand description
The socket: bind, read requests, hand them to the router, write responses. Loopback by
default; the bound address is reported so that a caller who asked for port 0, or whose
port was taken, learns the one in use. A bound socket is accepted by a few worker
threads, and each request is answered on a thread of its own up to a bound, so a slow
request queues nothing behind it — not even the probe a client sends before it would
take the lease over — and the owner’s stdio session never waits on HTTP. Stopping is cooperative: every
worker is unblocked and joined, and an in-flight response is finished first. A stopped
server refuses the next connection: stop returns after the listening socket is closed. A connection
that reads no request within the declared deadline is closed (super::deadline), and a
request that finds every handler busy is refused rather than answered on a worker.
Structs§
Constants§
- MAX_
BODY_ BYTES - The largest request body accepted.
- MAX_
HANDLERS - How many requests are answered at once. A bound, so that a flood costs a fixed number of
threads; far above what clients of one checkout send, so that a few slow tool calls never
hold the probe up. Past it a request is answered 503, except the probe (
GET /), which a worker answers itself: it is cheap, and it is what decides whether this server keeps its lease (I2156). - WORKERS
- How many threads accept requests on one socket. They only accept: each request is answered
on a thread of its own (up to
MAX_HANDLERS), so a worker is free again at once and a lease probe is answered while tool calls run (I2126).
Functions§
- bind
- Bind
host:port;0picks a free port. The error names the address when it fails. - bind_
declared - Bind the address a deployment object declared. The accidental-bind warning does not
fire here and is not suppressed either: it asks “did you mean this”, and
sourceis the answer — the canonical object that said so, named in the log so the operator can read which file decided the address. A hosted process that bound loopback would be unreachable inside its own machine, which is why this path exists at all. - bind_
or_ fallback - Bind
host:port, and when that port is taken bind a free one instead, saying so on stderr. For a server whose port is a convenience rather than a contract. - stdin_
is_ a_ pipe - Is stdin a pipe or a socket, as when a parent process spawned us and holds the other end?
Asked of descriptor 0 itself (
fstat), never of the path/dev/stdin: the path resolves through/dev/fd, which some harnesses (a coverage runner, a sandbox) do not expose, and a wrong “no” here sendsserveinto the run-forever branch while its parent waits for it to end. - used_
within - Whether this process was used over HTTP within the last
window: a request answered in it, or a live channel open now. The idle timer asks this beside the MCP sessions.