I'm running some integration tests with REST API service.
The problem is that sometimes hardcoded port isn't free at the moment the test starts for the next time. Because it was opened by previous test and isn't closed by the system yet.
I use OWIN, the application is shut down at the moment the next test starts.
Could you please suggest me a good way to determine a free port on the system without opening it in advance and then closing it? Or say that it's not possible.
Because it could be not freed by the system yet, just as it happens already.