Start New Discussion within our Software Development Community

Hello all. I am working on a pop3 connection. The problem is that after i have connected , when i try to read the stream, it will work. Although the next time i read from it it will just stop my program execution and hang. Like as it its in some endless loop.

my pop3 server connection looks like this. It is missing the account information authorization, but it works and the server will send me a response . Its not about that though just the use of the ReadLine() function from StreamReader, isn't working right.

tcpclient = gcnew TcpClient();     

     // HOST NAME POP SERVER and gmail uses port number 995 for POP 

        tcpclient->Connect("pop.gmail.com", 995); 

    / / This is Secure Stream // opened the connection between client and POP Server 

       sslstream = gcnew System::Net::Security::SslStream(tcpclient->GetStream(), false); 
sslstream->ReadTimeout = readTimeout;
     // authenticate as client   

       sslstream->AuthenticateAsClient("pop.gmail.com"); 

  

      reader = gcnew System::IO::StreamReader(sslstream,           System::Text::Encoding::ASCII);

I read the stream like this.

Console::WriteLine( reader->ReadLine());

it works once.
but if i try to do it again, it will hang and i cant get past it. No matter what context that i use it in it doesn't work. Its a small thing that's screwing up days of work. Please help thanks.

Is the stream coming back as "lines"?
With a stream across gmail, should you just use Read(...)?

Also are you checking for the EndOfStream?

This article has been dead for over six months. Start a new discussion instead.