How do I generate a connection reset programatically?

Posted by Brock Adams on Stack Overflow See other posts from Stack Overflow or by Brock Adams
Published on 2010-09-22T20:56:26Z Indexed on 2011/01/09 5:54 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

Hi,

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:

  1. It cannot be a general IP block. The test client must still be able to see the test server when not triggering the condition.

  2. 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.

  3. Ideally, it would be triggered by fetching a specific web-page.

  4. 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.

© Stack Overflow or respective owner

Related posts about php

Related posts about python