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


C# TcpConnection.ReadUntil方法代码示例

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


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

示例1: 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

示例2: TestSendToTooManyRecipients

        public void TestSendToTooManyRecipients()
        {
            hMailServer.Accounts accounts = _domain.Accounts;
             SingletonProvider<TestSetup>.Instance.AddAccount(accounts, string.Format("[email protected]"), "test");

             var sock = new TcpConnection();
             sock.Connect(25);
             sock.ReadUntil("\r\n");
             string result;
             sock.Send("EHLO test.com\r\n");
             result = sock.ReadUntil("\r\n");
             Assert.IsTrue(result.StartsWith("250"));
             sock.Send("MAIL FROM: [email protected]\r\n");
             result = sock.ReadUntil("\r\n");
             Assert.IsTrue(result.StartsWith("250"));

             const int recipientCount = 51000;

             for (int i = 1; i <= recipientCount; i++)
             {
            string address = string.Format("test{0}@gmail.com", i);

            sock.Send(string.Format("RCPT TO: <{0}>\r\n", address));
            result = sock.ReadUntil("\r\n");
            if (i <= 50000)
            {
               Assert.IsTrue(result.StartsWith("250"));
            }
            else
            {
               Assert.IsFalse(result.StartsWith("250"));
            }

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

             }
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:40,代码来源:SMTP.cs


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