void OnEndConnectCB(IAsyncResult ar) { Connect_SO stateObj = (Connect_SO)ar.AsyncState; try { stateObj.UpdateContext(); _socket.EndConnect(ar); _reader.BeginReadResponse(stateObj.Timeout, new AsyncCallback(this.OnResponse), stateObj); } catch (SocketException e) { if (_disposed) { stateObj.Exception = GetDisposedException(); } else if (e.ErrorCode == SockErrors.WSAETIMEDOUT) { stateObj.Exception = GetTimeoutException(e); } else { stateObj.Exception = e; } stateObj.SetCompleted(); } catch (Exception e) { if (_disposed) { stateObj.Exception = GetDisposedException(); } else { stateObj.Exception = e; } stateObj.SetCompleted(); } catch { if (_disposed) { stateObj.Exception = GetDisposedException(); stateObj.SetCompleted(); } else { NSTrace.WriteLineError("Non-CLS exception at: " + Environment.StackTrace); throw; } } }
internal override void EndEstablish(IAsyncResult ar) { try { _socket.EndConnect(ar); _stream = new NetworkStreamEx(_socket); } catch (SocketException e) { CheckDisposed(); CheckTimeoutException(e); throw; } catch { CheckDisposed(); throw; } }