public void Init()
        {
            _twoWayPipe = new DuplexCommunicationPipe();
            _Reader = new StreamReader(_twoWayPipe.Stream1);
            _Writer = new StreamWriter(_twoWayPipe.Stream1);
            _Writer.NewLine = "\r\n";
            _Writer.AutoFlush = true;

            _StreamProcessor = new SmtpStreamProcessor(_twoWayPipe.Stream2);
            new Action(_StreamProcessor.Process).BeginInvoke(null, null);
        }
Esempio n. 2
0
        private void ProcessClient(TcpClient client, TcpListener listener, ScopedActivity activity)
        {
            ListenerInfo info = _ListenerInfos[listener];
            try
            {
                info.Clients.Add(client);

                //gather some metrics...
                activity.Log("Client: {0}", client.Client.RemoteEndPoint);
                activity.Log("Active Connections for Listener: {0}", info.Clients.Count);

                //run validation checks...
                if (ValidateClient(client, activity))
                {
                    //process client
                    activity.Log("Exchanging Commands");
                    using (SmtpStreamProcessor clientProcessor = new SmtpStreamProcessor(client.GetStream(), info.SecurityMode, ServerCertificate))
                    {
                        clientProcessor.Process();
                    }
                }
            }
            finally
            {
                info.Clients.Remove(client);
                client.Close();
            }
        }