I'm sure you've seen the "the connection was reset" message displayed when trying to browse web pages.  (The text is from Firefox, other browsers differ.)
I need to generate that message/error/condition on demand, to test workarounds.
So, how do I generate that condition programmatically?  (How to generate a TCP RST from PHP -- or one of the other web-app languages?)
Caveats and Conditions:

It cannot be a general IP block.  The test client must still be able to see the test server when not triggering the condition.
Ideally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.).   Access to routers is problematic.  Access to Apache config is a pain.
Ideally, it would be triggered by fetching a specific web-page.
Bonus if it works on a standard, commercial web host.

Update:
Sending RST is not enough to cause this condition.  See my partial answer, below.
I've a solution that works on a local machine, Now need to get it working on a remote host.
I believe you need to close the low-level socket fairly abruptly. You won't be able to do it from Javascript. For the other languages you'll generally need to get a handle on the underlying socket object and close() it manually.
I also doubt you can do this through Apache since it is Apache and not your application holding the socket. At best your efforts are likely to generate a HTTP 500 error which is not what you're after.
How do I generate a connection reset programatically?