Check host port availability

I think try/catch is your only option, even if there was a way to check availability, without some sort of atomic “check/listen” or “check/reserve” operation there would be a race condition between checking availability and actually listening, so you would always have to handle the listen throwing an exception.

1 Like