internal static void TestEndPoint(IPEndPoint endPoint, out SmtpConnectivityStatusCode statusCode, out string details)
 {
     statusCode = SmtpConnectivityStatusCode.Success;
     details    = string.Empty;
     using (Socket socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
     {
         try
         {
             socket.Connect(endPoint);
             if (!socket.Connected)
             {
                 statusCode = SmtpConnectivityStatusCode.Error;
                 details    = Strings.UnableToConnect;
             }
             else
             {
                 byte[] array   = new byte[2000];
                 int    count   = socket.Receive(array, array.Length, SocketFlags.None);
                 string @string = Encoding.ASCII.GetString(array, 0, count);
                 TestSmtpConnectivity.ParseBanner(@string, out statusCode, out details);
             }
         }
         catch (SocketException ex)
         {
             statusCode = SmtpConnectivityStatusCode.Error;
             details    = ex.Message;
         }
     }
 }
 protected override void InternalProcessRecord()
 {
     base.InternalProcessRecord();
     TaskLogger.LogEnter();
     try
     {
         foreach (ReceiveConnector receiveConnector in this.receiveConnectors)
         {
             foreach (IPBinding ipbinding in receiveConnector.Bindings)
             {
                 Exception ex = null;
                 try
                 {
                     IList <IPEndPoint> endPoints = TestSmtpConnectivity.GetEndPoints(this.server, ipbinding);
                     foreach (IPEndPoint endPoint in endPoints)
                     {
                         SmtpConnectivityStatus status = TestSmtpConnectivity.GetStatus(this.server, receiveConnector, ipbinding, endPoint);
                         base.WriteObject(status);
                         if (this.MonitoringContext)
                         {
                             this.AddMonitoringData(status);
                         }
                     }
                 }
                 catch (ManagementException ex2)
                 {
                     ex = ex2;
                 }
                 catch (COMException ex3)
                 {
                     ex = ex3;
                 }
                 catch (UnauthorizedAccessException ex4)
                 {
                     ex = ex4;
                 }
                 if (ex != null)
                 {
                     SmtpConnectivityStatus smtpConnectivityStatus = new SmtpConnectivityStatus(this.server, receiveConnector, ipbinding, ipbinding);
                     smtpConnectivityStatus.StatusCode = SmtpConnectivityStatusCode.UnableToComplete;
                     smtpConnectivityStatus.Details    = ex.Message;
                     base.WriteObject(smtpConnectivityStatus);
                     if (this.MonitoringContext)
                     {
                         this.AddMonitoringData(smtpConnectivityStatus);
                     }
                 }
             }
         }
     }
     finally
     {
         if (this.MonitoringContext)
         {
             this.WriteMonitoringObject();
         }
         TaskLogger.LogExit();
     }
 }
 private void WriteMonitoringObject()
 {
     if (this.results != null)
     {
         MonitoringEvent item = TestSmtpConnectivity.CreateMonitoringEvent(this.server.Name, this.results);
         this.monitoringData.Events.Add(item);
     }
     base.WriteObject(this.monitoringData);
 }
        internal static SmtpConnectivityStatus GetStatus(Server server, ReceiveConnector connector, IPBinding binding, IPEndPoint endPoint)
        {
            SmtpConnectivityStatusCode statusCode;
            string details;

            TestSmtpConnectivity.TestEndPoint(endPoint, out statusCode, out details);
            return(new SmtpConnectivityStatus(server, connector, binding, endPoint)
            {
                StatusCode = statusCode,
                Details = details
            });
        }
 private bool ServerHasBindings()
 {
     this.receiveConnectors = TestSmtpConnectivity.GetReceiveConnectors((IConfigurationSession)base.DataSession, this.server);
     if (this.receiveConnectors.Count == 0)
     {
         this.WriteErrorAndAddMonitoringEvent(new NoReceiveConnectorsException(this.server.Fqdn), ErrorCategory.InvalidData, SmtpConnectivityStatusCode.Error);
         return(false);
     }
     if (!TestSmtpConnectivity.ConnectorsHaveBindings(this.receiveConnectors))
     {
         this.WriteErrorAndAddMonitoringEvent(new NoBindingsException(this.server.Fqdn), ErrorCategory.InvalidData, SmtpConnectivityStatusCode.Error);
         return(false);
     }
     return(true);
 }