API Index — Namespaces, Packages, Reports, Indices
FcgiTransport
in
Socket transport for {@see FastCgiClient} (#289).
The FastCGI protocol framing in FastCgiClient is transport-agnostic — only
three operations touch the socket: connect, send, and receive. This interface
abstracts those three so the client can run over EITHER:
- FcgiCoroutineTransport —
OpenSwoole\Coroutine\Client; yields under the event loop. Used when already inside a coroutine (getCid() >= 0). - FcgiBlockingTransport — plain
stream_socket_clientwith blockingfread/fwrite. Used when OUTSIDE a coroutine (getCid() < 0), e.g. thelegacy-cgi/superglobals(true)lifecycles where the request handler is NOT coroutine-wrapped.
Why this exists: #261 fixed an "API must be called in the coroutine" fatal by
wrapping the coroutine client in Coroutine::run() when outside a coroutine.
But that nests a fresh scheduler INSIDE the OpenSwoole reactor callback — the
reactor is parked waiting for the scheduler, which needs the reactor to deliver
the socket-readable event, so the FCGI read never completes and every request
HANGS until cgi_timeout (#289). A blocking socket has no scheduler to deadlock,
which is the semantically correct behaviour for the synchronous, one-request-at-
a-time legacy-cgi worker.
Table of Contents
Methods
- close() : void
- Close the connection (idempotent).
- connect() : void
- Open the connection to the FastCGI backend.
- recv() : string
- Receive up to
$maxLenbytes. Returns''on a clean EOF (peer closed). - send() : void
- Send all bytes to the backend.
Methods
close()
Close the connection (idempotent).
public
close() : void
connect()
Open the connection to the FastCGI backend.
public
connect() : void
Tags
recv()
Receive up to $maxLen bytes. Returns '' on a clean EOF (peer closed).
public
recv(int $maxLen) : string
Parameters
- $maxLen : int
Tags
Return values
stringsend()
Send all bytes to the backend.
public
send(string $data) : void
Parameters
- $data : string