T
Terry Olsen
Need a little help with reading from a network stream. I'm downloading
articles from an NNTP server. The end of an article is signified by
<CRLF>.<CRLF>
For all the talking back & forth, I used a regular StreamReader &
StreamWriter. This works great except when i'm downloading a yEncoded binary
article. So I have to use the NetworkStream object. However, it's not so
easy now to know when I've hit the end of the article. Here's the code I'm
trying to use:
Dim buf(1024) As Byte
Dim fs As New FileStream(FileName, FileMode.Create)
Dim ns As NetworkStream = _NNTPClient.GetStream
Do
Dim x As Integer = ns.Read(buf, 0, buf.Length)
fs.Write(buf, 0, x)
Loop While ns.DataAvailable = True
fs.Close()
I never get more than 2 or 3 Kb's of an article before the loop ends because
DataAvailable is False. I found that if I put a messagebox in the loop and
click on it each time it pops up, I get the entire article. I don't want to
put an artificial delay in the loop (such as a sleep statement), but I can't
figure out how to get all of the article.
Is there a method for scanning the incoming data for the <CRLF>.<CRLF>
pattern?
..
..
articles from an NNTP server. The end of an article is signified by
<CRLF>.<CRLF>
For all the talking back & forth, I used a regular StreamReader &
StreamWriter. This works great except when i'm downloading a yEncoded binary
article. So I have to use the NetworkStream object. However, it's not so
easy now to know when I've hit the end of the article. Here's the code I'm
trying to use:
Dim buf(1024) As Byte
Dim fs As New FileStream(FileName, FileMode.Create)
Dim ns As NetworkStream = _NNTPClient.GetStream
Do
Dim x As Integer = ns.Read(buf, 0, buf.Length)
fs.Write(buf, 0, x)
Loop While ns.DataAvailable = True
fs.Close()
I never get more than 2 or 3 Kb's of an article before the loop ends because
DataAvailable is False. I found that if I put a messagebox in the loop and
click on it each time it pops up, I get the entire article. I don't want to
put an artificial delay in the loop (such as a sleep statement), but I can't
figure out how to get all of the article.
Is there a method for scanning the incoming data for the <CRLF>.<CRLF>
pattern?
..
..