Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Output Streamreader

I have an HTTP POST  using
 Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

After posting the WebRequest

I have this
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)

How do I gkeep my connection open and just receive Debug.Writeline everything that comes through...never closing the connection?

I can receive the first "chunk" no problem using the following code...but it will exit after the first chunk
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
        Dim streamRead As New StreamReader(streamResponse)
        Dim readBuff(12560) As [Char]
        Dim count As Integer = streamRead.Read(readBuff, 0, 12560)

        Debug.WriteLine(count)
        Debug.WriteLine(ControlChars.Cr + "The contents of the HTML page are :  ")
        If count = 0 Then
            GoTo TheStart
        Else
            While count > 0
                Dim outputData As New [String](readBuff, 0, count)
                Debug.WriteLine(outputData)
                count = streamRead.Read(readBuff, 0, 12560)
            End While
        End If

Open in new window


Edit:
https://www.experts-exchange.com/R_21101.html
Modulus_Twelve
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

CodeCruiser,
  I have the KeepAlive set to true already.

How do I do the loop on the response stream?
Doesn't it require a buffer?
CodeCruiser...

Added this...

While streamResponse.CanRead

And refreshed the buffer inside each cycle on the output

THANKS!!!!

Remind me to buy you a Sody-Pop!

Been on this for 10 days
Glad it worked :-)
Man...I tell you what.

I went bin circles for a while.  Thanks...You know how it is when you're too close to something

Fresh eyes are needed.