Solved

Output Streamreader

Posted on 2013-06-18
5
207 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now