Beispiel #1
0
        static void Main(string[] args)
        {
            Console.Title = "Server";
            IPAddress   localAddr = IPAddress.Parse("192.168.1.44");
            IPEndPoint  endPoint  = new IPEndPoint(localAddr, 587);
            TcpListener listener  = new TcpListener(endPoint);

            listener.Start(100);

            while (true)
            {
                try
                {
                    TcpClient  client  = listener.AcceptTcpClient();
                    SMTPServer handler = new SMTPServer();
                    handler.Init(client);
                    Thread thread = new System.Threading.Thread(new ThreadStart(handler.Run));
                    thread.Start();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Thread.Sleep(3000);
                }
            }
        }
Beispiel #2
0
        private async Task RunSMTP()
        {
            IPEndPoint  endPoint = new IPEndPoint(IPAddress.Any, 25);
            TcpListener listener = new TcpListener(endPoint);

            listener.Start();

            while (true)
            {
                // Note that code stays here, until someone tries to connect to it. So this loop doesn't run continuously.
                TcpClient client = await listener.AcceptTcpClientAsync();

                SMTPServer handler = new SMTPServer();
                servers.Add(handler);
                handler.Init(client);
                Thread thread = new Thread(new ThreadStart(async() => { await handler.Run(); }));
                thread.Start();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            SMTPServer server = new SMTPServer();

            server.RunServer();
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MailListener"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="localaddr">The localaddr.</param>
 /// <param name="port">The port.</param>
 public MailListener(SMTPServer server, IPAddress localaddr, int port)
     : base(localaddr, port)
 {
     owner = server;
 }