I use netcat to simulate a network connectivity failures.
For instance, if server:port 1000 is the normal host and port my application would connect to, I set up a forward from port 2000:
nc -L server:1000 2000
then run my application to connect to localhost:2000
my_application --server=localhost --port=2000
Now my application is connected to localhost:2000, which is forwarded to server:1000 through netcat. To simulate a network connectivity failure I just kill netcat.
For instance, if server:port 1000 is the normal host and port my application would connect to, I set up a forward from port 2000:
then run my application to connect to localhost:2000 Now my application is connected to localhost:2000, which is forwarded to server:1000 through netcat. To simulate a network connectivity failure I just kill netcat.