当前位置: 首页>>代码示例>>C#>>正文


C# TcpConnection.Receive方法代码示例

本文整理汇总了C#中RegressionTests.Shared.TcpConnection.Receive方法的典型用法代码示例。如果您正苦于以下问题:C# TcpConnection.Receive方法的具体用法?C# TcpConnection.Receive怎么用?C# TcpConnection.Receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RegressionTests.Shared.TcpConnection的用法示例。


在下文中一共展示了TcpConnection.Receive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestExcessiveDataInIMAPConversation

        public void TestExcessiveDataInIMAPConversation()
        {
            var sb = new StringBuilder();
             for (int i = 0; i < 100000; i++)
             {
            sb.Append("1234567890");
             }

             sb.Append(".com\r\n");

             string command = "A03 NOOP " + sb;

             var socket = new TcpConnection();
             CustomAssert.IsTrue(socket.Connect(143));
             socket.Receive();
             socket.Send(command);

             try
             {
            string response = socket.Receive();
            CustomAssert.IsTrue(response.StartsWith("* BYE"));
             }
             catch (System.IO.IOException ex)
             {
            AssertIsConnectionTerminatedException(ex);
             }

             socket.Disconnect();
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:29,代码来源:ContentStressTest.cs

示例2: TestExcessiveDataInPOP3Conversation

        public void TestExcessiveDataInPOP3Conversation()
        {
            var sb = new StringBuilder();
             for (int i = 0; i < 100000; i++)
             {
            sb.Append("1234567890");
             }

             string command = "HELP " + sb;

             var socket = new TcpConnection();
             CustomAssert.IsTrue(socket.Connect(110));
             socket.Receive();
             socket.Send(command + "\r\n");

             try
             {
            string response = socket.Receive();
            CustomAssert.IsTrue(response.StartsWith("-ERR"));

            socket.Disconnect();
             }
             catch (IOException ex)
             {
            AssertIsConnectionTerminatedException(ex);
             }
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:27,代码来源:ContentStressTest.cs

示例3: Send100MBMessage

        public void Send100MBMessage()
        {
            long memoryUsage = Shared.GetCurrentMemoryUsage();

             _application.Settings.MaxMessageSize = 0;

             TcpConnection socket = new TcpConnection();
             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 = 1; i <= 100; i++)
             {
            Shared.AssertLowMemoryUsage(memoryUsage + 30);

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

            if ((i % 10) == 0)
            {
               TestTracer.WriteTraceInfo("{0}/{1}", i, 1000);
            }
             }

             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();

             Pop3ClientSimulator.AssertMessageCount(_domain.Accounts[0].Address, "test", 1);
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:60,代码来源:POP3.cs

示例4: IfStartTlsNotEnabledStartTlsShouldNotBeShownInEhloResponse

        public void IfStartTlsNotEnabledStartTlsShouldNotBeShownInEhloResponse()
        {
            var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25);
             var data1 = smtpClientSimulator.Receive();
             var data = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");

             Assert.IsFalse(data.Contains("STARTTLS"));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:9,代码来源:SmtpServerTests.cs

示例5: IfStlsRequiredLogonShouldFailIfNoStls

        public void IfStlsRequiredLogonShouldFailIfNoStls()
        {
            var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25003);
             var banner = smtpClientSimulator.Receive();
             var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
             Assert.IsTrue(capabilities1.Contains("STARTTLS"));

             var loginResult = smtpClientSimulator.SendAndReceive("AUTH LOGIN\r\n");
             Assert.IsTrue(loginResult.StartsWith("530 Must issue STARTTLS first."));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:11,代码来源:SmtpServerTests.cs

示例6: AuthShouldUpdateLastLogonTime

        public void AuthShouldUpdateLastLogonTime()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             DateTime lastLogonTimeBefore = Convert.ToDateTime(account.LastLogonTime);

             Thread.Sleep(1000);
             var sock = new TcpConnection();
             sock.Connect(25);
             CustomAssert.IsTrue(sock.Receive().StartsWith("220"));
             sock.Send("EHLO test.com\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("250"));

             string base64EncodedUsername = EncodeBase64("[email protected]");
             sock.Send("AUTH LOGIN " + base64EncodedUsername + "\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("334"));

             sock.Send(EncodeBase64("test") + "\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("235"));

             DateTime lastLogonTimeAfter =
            Convert.ToDateTime(SingletonProvider<TestSetup>.Instance.GetApp().Domains[0].Accounts[0].LastLogonTime);
             CustomAssert.AreNotEqual(lastLogonTimeBefore, lastLogonTimeAfter);
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:23,代码来源:Basics.cs

示例7: IfStlsOptionalButSslRequiredByIpRangeForAuthThenAuthShouldFail

        public void IfStlsOptionalButSslRequiredByIpRangeForAuthThenAuthShouldFail()
        {
            var range = SingletonProvider<TestSetup>.Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");
             range.RequireSSLTLSForAuth = true;
             range.Save();

             var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25002);
             var banner = smtpClientSimulator.Receive();
             var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
             Assert.IsTrue(capabilities1.Contains("STARTTLS"));

             var loginResult = smtpClientSimulator.SendAndReceive("AUTH LOGIN\r\n");
             Assert.IsTrue(loginResult.StartsWith("530 A SSL/TLS-connection is required for authentication.")); // must run starttls first.
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:15,代码来源:SmtpServerTests.cs

示例8: HandshakeCompletionShouldBeLoggedWithCipherDetails

        public void HandshakeCompletionShouldBeLoggedWithCipherDetails()
        {
            var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25002);
             var banner = smtpClientSimulator.Receive();
             var capabilities1 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");
             Assert.IsTrue(capabilities1.Contains("STARTTLS"));

             smtpClientSimulator.SendAndReceive("STARTTLS\r\n");
             smtpClientSimulator.HandshakeAsClient();

             var capabilities2 = smtpClientSimulator.SendAndReceive("EHLO example.com\r\n");

             var default_log = LogHandler.ReadCurrentDefaultLog();

             Assert.IsTrue(default_log.Contains("Version: TLS"));
             Assert.IsTrue(default_log.Contains("Cipher: "));
             Assert.IsTrue(default_log.Contains("Bits: "));
        }
开发者ID:baa-archieve,项目名称:hmailserver,代码行数:19,代码来源:SmtpServerTests.cs

示例9: TestSMTPServerAuthLoginUsernameAsThirdParameter

        public void TestSMTPServerAuthLoginUsernameAsThirdParameter()
        {
            _settings.AllowSMTPAuthPlain = true;

             var sock = new TcpConnection();
             sock.Connect(25);
             CustomAssert.IsTrue(sock.Receive().StartsWith("220"));
             sock.Send("EHLO test.com\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("250"));

             string base64EncodedUsername = EncodeBase64(GetUsername());
             sock.Send("AUTH LOGIN " + base64EncodedUsername + "\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("334"));

             sock.Send(EncodeBase64(GetPassword()) + "\r\n");
             CustomAssert.IsTrue(sock.Receive().StartsWith("535"));
             EnsureNoPassword();
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:18,代码来源:PasswordMasking.cs

示例10: AssertValidMailRcptToCommand

        private void AssertValidMailRcptToCommand(string comamnd)
        {
            var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25);
             Assert.IsTrue(smtpClientSimulator.Receive().StartsWith("220"));
             smtpClientSimulator.Send("HELO test\r\n");
             Assert.IsTrue(smtpClientSimulator.Receive().StartsWith("250"));
             smtpClientSimulator.Send("MAIL FROM: <[email protected]>\r\n");
             Assert.IsTrue(smtpClientSimulator.Receive().StartsWith("250"));

             string result = smtpClientSimulator.SendAndReceive(comamnd + "\r\n");

             smtpClientSimulator.Disconnect();

             Assert.AreEqual("250 OK\r\n", result);
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:16,代码来源:RcptToParsing.cs

示例11: TestPOP3DownloadOfLargeMessage

        public void TestPOP3DownloadOfLargeMessage()
        {
            Send100MBMessage();

             Pop3ClientSimulator.AssertMessageCount("[email protected]", "test", 1);

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

             // Receive welcome message.
             socket.Receive();

             socket.Send("USER " + "[email protected]" + "\r\n");
             socket.ReadUntil("+OK");

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

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

             var endOfResponseSB = new StringBuilder();

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

            endOfResponseSB.Append(socket.Receive());

            if (endOfResponseSB.Length > 100)
               endOfResponseSB.Remove(0, endOfResponseSB.Length - 100);

            endOfResponse = endOfResponseSB.ToString();
             }

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

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

             socket.Disconnect();
        }
开发者ID:SpivEgin,项目名称:hmailserver,代码行数:47,代码来源:POP3.cs

示例12: TestLongSMTPDataSessionWithoutNewline

        public void TestLongSMTPDataSessionWithoutNewline()
        {
            long memoryUsage = Shared.GetCurrentMemoryUsage();

             var socket = new TcpConnection();
             socket.Connect(25);
             socket.Receive();

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

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

             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 = 1; i <= 1000; i++)
             {
            Shared.AssertLowMemoryUsage(memoryUsage + 30);

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

            if ((i%10) == 0)
            {
               TestTracer.WriteTraceInfo("{0}/{1}", i, 1000);
            }
             }

             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");
             socket.Receive();

             socket.Disconnect();
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:55,代码来源:SMTP.cs

示例13: MailFromWithAuthParameterShouldBeAccepted

        public void MailFromWithAuthParameterShouldBeAccepted()
        {
            Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var smtpClientSimulator = new TcpConnection();
             smtpClientSimulator.Connect(25);

             Assert.IsTrue(smtpClientSimulator.Receive().StartsWith("220"));
             smtpClientSimulator.Send("HELO test\r\n");
             Assert.IsTrue(smtpClientSimulator.Receive().StartsWith("250"));

             // A few tests of invalid syntax.
             Assert.IsTrue(smtpClientSimulator.SendAndReceive("MAIL FROM: <[email protected]> AUTH=<>\r\n").StartsWith("250"));

             smtpClientSimulator.Disconnect();
        }
开发者ID:hmailserver,项目名称:hmailserver,代码行数:16,代码来源:Basics.cs

示例14: TestMailFromSyntaxValidation

        public void TestMailFromSyntaxValidation()
        {
            Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var oSMTP = new TcpConnection();
             oSMTP.Connect(25);

             CustomAssert.IsTrue(oSMTP.Receive().StartsWith("220"));
             oSMTP.Send("HELO test\r\n");
             CustomAssert.IsTrue(oSMTP.Receive().StartsWith("250"));

             // A few tests of invalid syntax.
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <[email protected]\r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: [email protected]>\r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <    [email protected]    \r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <        \r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: >        \r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM: <[email protected]\r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM <[email protected]>\r\n").StartsWith("250"));
             CustomAssert.IsFalse(oSMTP.SendAndReceive("MAIL FROM  [email protected]\r\n").StartsWith("250"));

             // Valid syntax, < and >
             CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: <[email protected]>\r\n").StartsWith("250"));
             CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));

             CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM: [email protected]\r\n").StartsWith("250"));
             CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));

             CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM:    [email protected]   \r\n").StartsWith("250"));
             CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));

             CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM:[email protected]\r\n").StartsWith("250"));
             CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));

             CustomAssert.IsTrue(oSMTP.SendAndReceive("MAIL FROM:<[email protected]>\r\n").StartsWith("250"));
             CustomAssert.IsTrue(oSMTP.SendAndReceive("RSET\r\n").StartsWith("250"));

             oSMTP.Disconnect();
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:39,代码来源:Basics.cs

示例15: TestEHLOKeywords

        public void TestEHLOKeywords()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();
             Settings settings = _settings;
             settings.HostName = "examplify.com";

             var socket = new TcpConnection();
             CustomAssert.IsTrue(socket.Connect(25));
             string result = socket.Receive();
             socket.Send("EHLO example.com\r\n");
             result = socket.Receive();
             socket.Disconnect();
             CustomAssert.IsTrue(result.Contains("250-" + settings.HostName));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:14,代码来源:Basics.cs


注:本文中的RegressionTests.Shared.TcpConnection.Receive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。