Socket.EndConnect doesn't throw exception
I've used the asychonous Socket methods quite a bit, but never bothered with .BeginConnect / .EndConnect, opting instead to use .Connect.
So I figured I'd try it just for kicks. I set up the IP address and port, and do not have anything listening on the port, so I fully expect to get a winsock error with the message "No connection could be made because the target machine actively refused it".
I get the expected SocketException when I use the .Connect method, but don't get it when I use the asynchronous methods. There's no exception on .EndConnect, yet the Socket of course isn't connected.
Anyone know why that is? I've searched around, but can't find anything useful.
Thanks,
Mike
Re: Socket.EndConnect doesn't throw exception
I dug up some old code where I did use the asynchronous .BeginConnect and .EndConnect. That was written in 1.1, my current stuff is in 2.0. Doesn't make a difference as it behaves the same way.
For some reason, the first attempt at .EndConnect does not produce the expected exception, but then if you do the .BeginConnect / .EndConnect a second time, you get the exception. Strange. Maybe I'll just stick with .Connect.
Mike