stream connection using httpwebrequest
I have created a httpwebrequest connection to a streaming API after trying a tTCPClient which just never ended up working.  My concern is whether my code is correct and that I am actually reading in new data and that the connection is maintained. Initially I had been reading into a buffer and just loaded everything into a file after max size, but figured it would be simpler to read a line, since each entry was being sent delimited by line feeds.

    rStream = webrequest.GetResponse().GetResponseStream
    rStream = New GZipStream(rStream, CompressionMode.Decompress)
    If rStream.CanRead then
       Dim bufferPit(8100) as byte
       Do
          Dim dStream as StreamReader = New StreamReader(rStream)
          While not dStream.EndOfStream
              rData = dStream.ReadLine()
              pTools.appendToFile(rData)
          End While
       .....//some other exception handling
       Loop While rStream.CanRead


Something does not seem right since it looks like I am continuously reading and not sure if I am reading redundant data here. Also another question is that if I were to use a thread to appendToFile, would that maintain the connection to the stream?

             
stream connection using httpwebrequest
===

I have created a httpwebrequest connection to a streaming API after trying a tTCPClient which just never ended up working.  My concern is whether my code is correct and that I am actually reading in new data and that the connection is maintained. Initially I had been reading into a buffer and just loaded everything into a file after max size, but figured it would be simpler to read a line, since each entry was being sent delimited by line feeds.

    rStream = webrequest.GetResponse().GetResponseStream
    rStream = New GZipStream(rStream, CompressionMode.Decompress)
    If rStream.CanRead then
       Dim bufferPit(8100) as byte
       Do
          Dim dStream as StreamReader = New StreamReader(rStream)
          While not dStream.EndOfStream
              rData = dStream.ReadLine()
              pTools.appendToFile(rData)
          End While
       .....//some other exception handling
       Loop While rStream.CanRead


Something does not seem right since it looks like I am continuously reading and not sure if I am reading redundant data here. Also another question is that if I were to use a thread to appendToFile, would that maintain the connection to the stream?

             