Summary description for ClientSocket.
예제 #1
0
        public IMAPSimulator(string username, string password, string mailbox)
        {
            m_oSocket = new TCPSocket();

               Assert.IsTrue(ConnectAndLogon(username, password));
               Assert.IsTrue(SelectFolder(mailbox));
        }
예제 #2
0
        public IMAPSimulator(string username, string password, string mailbox)
        {
            m_oSocket = new TCPSocket();

            Assert.IsTrue(ConnectAndLogon(username, password));
            Assert.IsTrue(SelectFolder(mailbox));
        }
예제 #3
0
        public void TestConnection()
        {
            for (int i = 0; i < 2500; i++)
            {
                TCPSocket socket = new TCPSocket();

                Assert.IsTrue(socket.CanConnect(25));
            }
        }
예제 #4
0
        public static void AssertClamDRunning()
        {
            Process[] processlist = Process.GetProcesses();

            foreach (Process theprocess in processlist)
            {
                if (theprocess.ProcessName == "clamd")
                {
                    return;
                }
            }

            // Check if we can launch it...
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = @"C:\clamav\clamd.exe";
            startInfo.WorkingDirectory = @"C:\Clamav";
            startInfo.Arguments        = "--daemon";

            try
            {
                System.Diagnostics.Process.Start(startInfo);

                // Wait for clamav to start up.
                for (int i = 0; i < 10; i++)
                {
                    TCPSocket sock = new TCPSocket();
                    if (sock.Connect(3310))
                    {
                        return;
                    }
                    System.Threading.Thread.Sleep(1000);
                }

                Assert.Fail("ClamD process not starting up.");
            }
            catch (Exception)
            {
                Assert.Ignore("Unable to start ClamD process. Is ClamAV installed?");
            }
        }
예제 #5
0
        public void TestManyTCPIPConnections()
        {
            Utilities.DeleteCurrentDefaultLog();

             const int count = 1000;

             List<TCPSocket> sockets = new List<TCPSocket>();
             for (int i = 0; i < count; i++)
             {
            TCPSocket socket = new TCPSocket();
            Assert.IsTrue(socket.Connect(25));

            sockets.Add(socket);
             }

             foreach (TCPSocket socket in sockets)
             {
            socket.Disconnect();
             }

             string log = Utilities.ReadCurrentDefaultLog();
        }
예제 #6
0
        public static void AssertClamDRunning()
        {
            Process[] processlist = Process.GetProcesses();

             foreach (Process theprocess in processlist)
             {
            if (theprocess.ProcessName == "clamd")
               return;
             }

             // Check if we can launch it...
             ProcessStartInfo startInfo = new ProcessStartInfo();
             startInfo.FileName = @"C:\clamav\clamd.exe";
             startInfo.WorkingDirectory = @"C:\Clamav";
             startInfo.Arguments = "--daemon";

             try
             {

            System.Diagnostics.Process.Start(startInfo);

            // Wait for clamav to start up.
            for (int i = 0; i < 10; i++)
            {
               TCPSocket sock = new TCPSocket();
               if (sock.Connect(3310))
                  return;
               System.Threading.Thread.Sleep(1000);
            }

            Assert.Fail("ClamD process not starting up.");
             }
             catch (Exception)
             {
            Assert.Ignore("Unable to start ClamD process. Is ClamAV installed?");
             }
        }
예제 #7
0
 public IMAPSimulator()
 {
     m_oSocket = new TCPSocket();
 }
예제 #8
0
        public void TestLongSMTPDataSessionWithoutNewline()
        {
            long memoryUsage = Shared.GetCurrentMemoryUsage();

            TCPSocket socket = new TCPSocket();
            socket.Connect(25);
            socket.Receive();

            socket.Send("HELO test.com\r\n");
            socket.Receive();

            // Build a large string...
            StringBuilder sb = new StringBuilder();
            sb.Append("A01");
            for (int i = 0; i < 10000; i++)
            {
                sb.Append("01234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890");
            }
            int length = sb.Length;

            socket.Send("MAIL FROM: [email protected]\r\n");
            socket.Receive();
            socket.Send("RCPT TO: [email protected]\r\n");
            socket.Receive();
            socket.Send("DATA\r\n");
            socket.Receive();

            for (int i = 0; i < 1000; i++)
            {
                Shared.AssertLowMemoryUsage(memoryUsage+30);

                try
                {
                    socket.Send(sb.ToString());
                }
                catch (Exception)
                {
                    return;
                }
            }

            socket.Send("\r\n.\r\n");
            string result = socket.Receive();

            Assert.IsTrue(result.StartsWith("554 Too long line was received. Transmission aborted."));

            socket.Send("QUIT\r\n");
            result = socket.Receive();

            socket.Disconnect();
        }
예제 #9
0
        public void TestPOP3DownloadOfLargeMessage()
        {
            TestLongSMTPDataSessionIncludingNewline();

            POP3Simulator.AssertMessageCount("*****@*****.**", "test", 1);

            TCPSocket socket = new TCPSocket();
            socket.Connect(110);

            // Receive welcome message.
            string sData = socket.Receive();

            socket.Send("USER " + "*****@*****.**" + "\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("PASS " + "test" + "\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("RETR 1\r\n");

            string sRetVal = "";
            while (sRetVal.IndexOf("\r\n.\r\n") < 0)
            {
                if (sRetVal.IndexOf("-ERR no such message") >= 0)
                {
                    socket.Disconnect();
                    Assert.Fail("Nope");
                }

                sRetVal = socket.Receive();

            }

            socket.Send("DELE 1\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("QUIT\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Disconnect();
        }
예제 #10
0
        public void TestLongSMTPCommand()
        {
            TCPSocket socket = new TCPSocket();
            socket.Connect(25);

            // Build a large string...
            StringBuilder sb = new StringBuilder();
            sb.Append("A01");
            for (int i = 0; i < 1000000; i++)
            {
                sb.Append("01234567890");
            }
            int length = sb.Length;

            sb.Append(Environment.NewLine);

            for (int i = 0; i < 100; i++)
            {
                try
                {
                    socket.Send(sb.ToString());
                }
                catch (Exception)
                {
                    return;
                }
            }

            socket.Send("\r\n");
            string result = socket.Receive();

            socket.Disconnect();
        }
예제 #11
0
        public void TestLongSMTPDataSessionIncludingNewline()
        {
            long memoryUsage = Shared.GetCurrentMemoryUsage();

               _application.Settings.MaxMessageSize = 0;

            TCPSocket socket = new TCPSocket();
            socket.Connect(25);
            socket.Receive();

            socket.Send("HELO test.com\r\n");
            socket.Receive();

            // Build a large string...
            StringBuilder sb = new StringBuilder();
            sb.Append("A01");
            for (int i = 0; i < 10000; i++)
            {
                sb.Append("01234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890\r\n");
            }
            int length = sb.Length;

            sb.Append(Environment.NewLine);

            socket.Send("MAIL FROM: [email protected]\r\n");
            socket.Receive();
            socket.Send("RCPT TO: [email protected]\r\n");
            socket.Receive();
            socket.Send("DATA\r\n");
            socket.Receive();

            for (int i = 0; i < 100; i++)
            {
                Shared.AssertLowMemoryUsage(memoryUsage+30);

                try
                {
                    socket.Send(sb.ToString());
                }
                catch (Exception)
                {
                    return;
                }
            }

            socket.Send("\r\n.\r\n");
            string result = socket.Receive();
            Assert.IsTrue(result.StartsWith("250"));

            socket.Send("QUIT\r\n");
            result = socket.Receive();
            socket.Disconnect();

            POP3Simulator.AssertMessageCount(_domain.Accounts[0].Address, "test", 1);
        }
예제 #12
0
 public POP3Simulator()
 {
     m_oSocket = new TCPSocket();
 }
예제 #13
0
 public POP3Simulator(IPAddress ipaddress, bool useSSL, int port)
 {
     m_oSocket = new TCPSocket(useSSL);
      _port = port;
      _ipaddress = ipaddress;
 }
예제 #14
0
 public IMAPSimulator(bool useSSL, int port)
 {
     m_oSocket = new TCPSocket(useSSL);
     _port     = port;
 }
예제 #15
0
 public IMAPSimulator(bool useSSL, int port)
 {
     m_oSocket = new TCPSocket(useSSL);
     _port = port;
 }
예제 #16
0
 public IMAPSimulator()
 {
     m_oSocket = new TCPSocket();
 }
예제 #17
0
 public SMTPSimulator(bool useSSL, int port, IPAddress ipaddress)
 {
     m_oSocket  = new TCPSocket(useSSL);
     _port      = port;
     _ipaddress = ipaddress;
 }
예제 #18
0
 public POP3Simulator(IPAddress ipaddress, bool useSSL, int port)
 {
     m_oSocket  = new TCPSocket(useSSL);
     _port      = port;
     _ipaddress = ipaddress;
 }
예제 #19
0
 public POP3Simulator()
 {
     m_oSocket = new TCPSocket();
 }
예제 #20
0
 public SMTPSimulator(bool useSSL, int port, IPAddress ipaddress)
 {
     m_oSocket = new TCPSocket(useSSL);
      _port = port;
      _ipaddress = ipaddress;
 }