<p>I have a network C++ program in Windows that I'd like to test for network disconnects at various times.  What are my options?</p>

<p>Currently I am:</p>

<ol>
<li>Actually disconnecting the network wire from the back of my computer</li>
<li>using ipconfig /release</li>
<li>Using the <a href="http://www.nirsoft.net/utils/cports.html" rel="nofollow noreferrer">cports</a> program to close out the socket completely</li>
</ol>

<p>None of these methods though are ideal for me, and I'd like to emulate network problems more easily. </p>

<p>I would like for sometimes connects to fail, sometimes socket reads to fail, and sometimes socket writes to fail.  It would be great if there was some utility I could use to emulate these types of problems.</p>

<p>It would also be nice to be able to build some automated unit tests while this emulated bad network is up.</p>

The closest I can think of is doing something similar with
VEDekstop
from Shunra..
Simulating High Latency and Low Bandwidth in Testing of Database Applications
Shunra VE Desktop Standard is a Windows-based client software solution that simulates a wide area network link so that you can test applications under a variety of current and potential network conditions – directly from your desktop.