Artificially create a connection timeout error

Mark Ingram picture Mark Ingram · Sep 19, 2008 · Viewed 143k times · Source

I've had a bug in our software that occurs when I receive a connection timeout. These errors are very rare (usually when my connection gets dropped by our internal network). How can I generate this kind of effect artificially so I can test our software?

If it matters the app is written in C++/MFC using CAsyncSocket classes.

Edit:

I've tried using a non-existent host, and I get the socket error:

WSAEINVAL (10022) Invalid argument

My next attempt was to use Alexander's suggestion of connecting to a different port, e.g. 81 (on my own server though). That worked great. Exactly the same as a dropped connection (60 second wait, then error). Thank you!

Answer

emu picture emu · May 24, 2009

Connect to a non-routable IP address, such as 10.255.255.1.