Solved

Output Streamreader

Posted on 2013-06-18
5
212 Views
Last Modified: 2013-06-24
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:
http://www.experts-exchange.com/R_21101.html
Modulus_Twelve
0
Comment
Question by:lrbrister
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39270906
Set the KeepAlive property of request to true and then call Read method of ReponseStream in a loop.
0
 

Author Comment

by:lrbrister
ID: 39271246
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?
0
 

Author Closing Comment

by:lrbrister
ID: 39271348
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
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39271379
Glad it worked :-)
0
 

Author Comment

by:lrbrister
ID: 39271388
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.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question