This is somehow a developer question, but as it is more related to operating systems and network connections, I will post it here and not on Stack Overflow.
I'm trying to simulate a situation when a network connection get closed because of a network problem or error, to test a behavior I implemented in one of my application. I could simply disconnect my network cable or shut down the network interface, but I made my application to reconnect immediately after this so doing that will take too long until the network will be up again (because of DHCP negotiating and etc.).
Is there any way, in Unix or OS X, to just disconnect a specific application from internet and then let it reconnect immediately? Maybe to simulate a "connection reset by peer" error or something (I'm not a pro when it comes about networking, so sorry for my newbie language).