1 Replies - 3156 Views - Last Post: 09 March 2012 - 07:20 AM

#1 JohnBoyMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 24-February 12

stream reader hanging when read from twice

Posted 09 March 2012 - 05:53 AM

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 This A Good Question/Topic? 0
  • +

Replies To: stream reader hanging when read from twice

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,224
  • Joined: 23-August 08

Re: stream reader hanging when read from twice

Posted 09 March 2012 - 07:20 AM

Not enough context. We don't know what you're doing in the interim.

And we have a forum for the abomination known as CLI C++, so I'll move this there for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1