G
Guest
I'm pretty new to VB .net and Network coding, what I'm trying to do is
interact with a NNTP server to retrieve a list of news groups.
When I run thru' debug I basically get what I'm after, when I run without
debug the results vary - which to me suggests it's some form of sync problem
with my 'writes and reads'.
I've set up a connection to a server and have sent a 'List' command to get a
'group list', I've set up my connection buffer at 32k, I'm assuming I'm
blocking on the stream read, the question is how to I control receiving a
complete returned message - which could be 500k. I've tried various do-loop
controls, some based on MSDN examples such as 'Loop While
NStream.DataAvailable' and the attached which I'd hoped would loop until a
message which was less then the complete buffer was returned - but it all
seems hit and miss.
thanks
Dim numberOfBytesRead As Integer = 0
Dim sb As New StringBuilder
Do
numberOfBytesRead = NStream.Read(bytes, 0, CInt
Connection.ReceiveBufferSize))
If numberOfBytesRead = 0 Then
Exit Do
End If
sb.Append(Encoding.ASCII.GetString(bytes, 0, numberOfBytesRead))
totallength = sb.Length
Loop Until numberOfBytesRead < Connection.ReceiveBufferSize
interact with a NNTP server to retrieve a list of news groups.
When I run thru' debug I basically get what I'm after, when I run without
debug the results vary - which to me suggests it's some form of sync problem
with my 'writes and reads'.
I've set up a connection to a server and have sent a 'List' command to get a
'group list', I've set up my connection buffer at 32k, I'm assuming I'm
blocking on the stream read, the question is how to I control receiving a
complete returned message - which could be 500k. I've tried various do-loop
controls, some based on MSDN examples such as 'Loop While
NStream.DataAvailable' and the attached which I'd hoped would loop until a
message which was less then the complete buffer was returned - but it all
seems hit and miss.
thanks
Dim numberOfBytesRead As Integer = 0
Dim sb As New StringBuilder
Do
numberOfBytesRead = NStream.Read(bytes, 0, CInt
Connection.ReceiveBufferSize))
If numberOfBytesRead = 0 Then
Exit Do
End If
sb.Append(Encoding.ASCII.GetString(bytes, 0, numberOfBytesRead))
totallength = sb.Length
Loop Until numberOfBytesRead < Connection.ReceiveBufferSize