ReadUntil() public méthode

public ReadUntil ( List possibleReplies ) : string
possibleReplies List
Résultat string
Exemple #1
0
        public bool ConnectAndLogon(string username, string password, out string errorMessage)
        {
            errorMessage = "";
            if (!m_oSocket.Connect(_ipaddress, _port))
            {
                return(false);
            }

            // Receive welcome message.
            errorMessage = m_oSocket.ReadUntil("+OK");
            if (!errorMessage.StartsWith("+OK"))
            {
                return(false);
            }

            m_oSocket.Send("USER " + username + "\r\n");

            errorMessage = m_oSocket.ReadUntil("+OK Send your password");
            if (!errorMessage.StartsWith("+OK"))
            {
                return(false);
            }

            m_oSocket.Send("PASS " + password + "\r\n");
            errorMessage = m_oSocket.ReadUntil(new List <string>()
            {
                "+OK", "-ERR"
            });

            return(errorMessage.StartsWith("+OK"));
        }
Exemple #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();
        }
Exemple #3
0
 public string ReceiveUntil(string characters)
 {
     return(m_oSocket.ReadUntil(characters));
 }