Artificially create a connection timeout error

Posted by Mark Ingram on Stack Overflow See other posts from Stack Overflow or by Mark Ingram
Published on 2008-09-19T09:57:47Z Indexed on 2010/03/12 15:07 UTC
Read the original article Hit count: 288

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-existant 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!

© Stack Overflow or respective owner

Related posts about networking

Related posts about network