tags:

views:

8

answers:

0

I have set up a streaming http connection and it now connects fine, but I need to read the stream and capture data by looking for the opening element and stop reading when I get the closing element . How would I implement this? Here is what I have so far? I tried using webclient and webrequest but it did not work as well so use tcpclient

 Dim tclient As TcpClient = New TcpClient(url, "80")
            nstream = tclient.GetStream()

            If nstream.CanWrite Then
                Dim sendbytes As [Byte]() = Encoding.UTF8.GetBytes("GET /stream.xml?")
                nstream.Write(sendbytes, 0, sendbytes.Length)
            Else
                tclient.Close()
                nstream.Close()
            End If
            If nstream.CanRead Then
                Dim bufferread(tclient.ReceiveBufferSize) As Byte
                mstring = New StringBuilder
                numbytesread = 0
                Do
                    numbytesread = nstream.Read(bufferread, 0, tclient.ReceiveBufferSize)
                    mstring.AppendFormat("{0}", Encoding.UTF8.GetString(bufferread, 0, numbytesread))


                Loop While nstream.DataAvailable

            End If