Hello experts, here is my code that I have a question on:
Dim receivedbyte(1024) As Byte
Dim myread As Integer = 0
Dim myresponsesb As New StringBuilder()
myread = myns.Read(receivedbyte, 0, receivedbyte.Length)
myresponsesb.Append(System.Text.Encoding.UTF8.GetString(receivedbyte, 0, myread))
Loop While (myns.DataAvailable)
In the above, myns is a networkstream that is initialized with a tcpclient that is communicating with a XMPP server. basically, iam getting back xml messages.
The issue with the above is that if I dont use thread.sleep(500), the complete data is not returned. Why is that? I have tried to use a streamreader instead of read and using that method i can get complete data from the stream. What am I doing wrong with the Read method of networkstream?
SECOND: The XML being returned from the server is not well formed - the closing tag for one of the tags is missing and I am unable to use XDocument to parse this XML because of this. What could be the issue here? Is it my code or something on server end?
Also, what technique should i use to make the returned XML well formed so that I can use XDOCUMENT and LINQ to parse this?
View Complete Post