Exemplo n.º 1
0
        protected virtual void OnConnectionAttemptFailed(SslEndPoint sslEndPoint, Exception e)
        {
            var handler = ConnectionAttemptFailed;

            if (null != handler)
            {
                handler(this, new ConnectionAttemptFailedEventArgs(sslEndPoint, e));
            }
        }
Exemplo n.º 2
0
        // Event dispatchers

        protected virtual void OnConnectionAttemptStarted(SslEndPoint sslEndPoint)
        {
            var handler = ConnectionAttemptStarted;

            if (null != handler)
            {
                handler(this, new ConnectionAttemptStartedEventArgs(sslEndPoint));
            }
        }
Exemplo n.º 3
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                ConnectionAttemptStarted = null;
                ConnectionAttemptFailed  = null;
                ConnectionFailed         = null;
                ConnectionEstablished    = null;

                EndPoints             = null;
                IPAddresses           = null;
                CurrentEndPoint       = null;
                CertificateCollection = null;
                Configuration         = null;

                if (null != EndPointEnumerator)
                {
                    EndPointEnumerator.Dispose( );
                    EndPointEnumerator = null;
                }
                if (null != TcpClient)
                {
                    TcpClient.Close( );
                    TcpClient = null;
                }
                if (null != _protocolHandler)
                {
                    _protocolHandler.Dispose( );
                    _protocolHandler = null;
                }
                if (null != _sslStream)
                {
                    _sslStream.Dispose( );
                    _sslStream = null;
                }
            }
        }
Exemplo n.º 4
0
        private void TryEstablishConnection( )
        {
            if (null == TcpClient)
            {
                TcpClient = new TcpClient( );
            }

            while (EndPointEnumerator.MoveNext( ))
            {
                CurrentEndPoint = EndPointEnumerator.Current;
                Debug.Print("ServerConnector.TryEstablishConnection: trying {0}", CurrentEndPoint);
                OnConnectionAttemptStarted(CurrentEndPoint);

                try {
                    TcpClient.BeginConnect(CurrentEndPoint.Address, CurrentEndPoint.Port, ConnectCallback, null);
                    return;
                }
                catch (NotSupportedException e) {
                    Debug.Print("ServerConnector.TryEstablishConnection: TcpClient.BeginConnect: caught NotSupportedException:\n{0}", e);
                }
                catch (Exception e) {
                    Debug.Print("ServerConnector.TryEstablishConnection: TcpClient.BeginConnect: caught exception:\n{0}", e);
                }
            }

            if (null != TcpClient)
            {
                SocketRegistry.Unregister(TcpClient.Client.LocalEndPoint as IPEndPoint);
                TcpClient.Close( );
                TcpClient = null;
            }

            EndPointEnumerator.Dispose( );
            EndPoints = null;

            OnConnectionFailed(new Exception("Ran out of IP addresses and ports to try."));
        }
Exemplo n.º 5
0
 public ConnectionAttemptFailedEventArgs(SslEndPoint sslEndPoint, Exception e)
 {
     SslEndPoint = sslEndPoint;
     Exception   = e;
 }
Exemplo n.º 6
0
 public ConnectionAttemptStartedEventArgs(SslEndPoint sslEndPoint)
 {
     SslEndPoint = sslEndPoint;
 }