Receive() public method

public Receive ( ) : string
return string
Ejemplo n.º 1
0
        public string GetWelcomeMessage()
        {
            m_oSocket.Connect(_ipaddress, _port);
            string sData = m_oSocket.Receive();

            m_oSocket.Disconnect();
            return(sData);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 public string Receive()
 {
     return(m_oSocket.Receive());
 }
Ejemplo n.º 7
0
        public string Connect()
        {
            m_oSocket.Connect(_port);
            string sData = m_oSocket.Receive();

            return(sData);
        }