In my application, I need to connect to my WebSocket server. The thing is - I don't know when that server is up. It can happen while the application itself is running. So I somehow need to monitor that port until I notice something like "a server is now listening on that port" after that I connect to the server automatically.
I could let the user press a button that tries to connect to the server
or I could keep trying to establish a connection using a for loop and a timeout. However, I think that would be a bad solution. Is there a better way?