Is there a way to make a socket stop trying to connect immediately? It seems if the socket tries to connect a dud it takes a certain amount of time to timeout on the connection. If the user clicks a button trying to connect, then wants to close, the other threads keeps the application alive because it is stuck blocking at the socket.Connect() method.
I have tried calling close from another thread. The exception changes but the timeout is still there. It is annoying to have to wait for the timeout.
You could use the async method BeginConnect in conjunction with EndConnect to avoid blocking the main thread. As far as the timeout is concerned you may try to decrease its value.