Fixes #41616
ConnectAsyncCallback now throws an exception when called a second time.
ConnectAsync reuses SocketAsyncEventArgs in BeginConnect which
already updates its state and calls ConnectAsyncCallback.
The changes make sure that ConnectAsyncCallback no longer called on
ConnectAsync catch block, while the state is still updated with the
exception.
if (e.RemoteEndPoint == null)
throw new ArgumentNullException ("remoteEP");
- InitSocketAsyncEventArgs (e, ConnectAsyncCallback, e, SocketOperation.Connect);
+ InitSocketAsyncEventArgs (e, null, e, SocketOperation.Connect);
try {
IPAddress [] addresses;