public void BeginConnect(string address, int port, SslCertBundleSettings bundleSettings, SslSocket.BeginConnectDelegate connectDelegate)
 {
     this.m_beginConnectDelegate  = connectDelegate;
     this.m_bundleSettings        = bundleSettings;
     this.m_connection.LogDebug   = new Action <string>(SslSocket.s_log.LogDebug);
     this.m_connection.LogWarning = new Action <string>(SslSocket.s_log.LogWarning);
     this.m_connection.OnFailure  = () => this.ExecuteBeginConnectDelegate(true);
     this.m_connection.OnSuccess  = new Action(this.ConnectCallback);
     this.m_connection.Connect(address, port);
 }
        private void ExecuteBeginConnectDelegate(bool connectFailed)
        {
            this.m_bundleSettings = null;
            if (this.m_beginConnectDelegate == null)
            {
                return;
            }
            bool isEncrypted = false;
            bool isSigned    = false;

            if (this.m_sslStream != null)
            {
                isEncrypted = this.m_sslStream.IsEncrypted;
                isSigned    = this.m_sslStream.IsSigned;
            }
            this.m_beginConnectDelegate(connectFailed, isEncrypted, isSigned);
            this.m_beginConnectDelegate = null;
            SslSocket.s_log.LogDebug("Connected={0} isEncrypted={1} isSigned={2}", new object[] { !connectFailed, isEncrypted, isSigned });
        }