PHP可以关闭与客户端的连接吗?

I'm writing a mock webservice, and besides legit responses I also want to generate various error conditions to see how my code responds to them. One of those would be an aborted connection. That is, I want to return NOTHING. Not even HTTP headers, not even the status line. Just brutally close the underlying TCP socket as soon as the request is received. This simulates some catastrophic error in the webservice.

Is this possible at all? Is it possible if my webserver is Apache? What about the built in webserver?

You need something like Toxiproxy.

Toxiproxy is a framework for simulating network conditions. It's made specifically to work in testing, CI and development environments, supporting deterministic tampering with connections, but with support for randomized chaos and customization. Toxiproxy is the tool you need to prove with tests that your application doesn't have single points of failure.

You can use the down call as explained in the docs https://github.com/shopify/toxiproxy#down