When reading from a network stream using the following code:
I tend to get the data in two or more chunks, unless I specify a delay after each buffer read (which is hardly desirable). It is usually a problem with 4k+ buffers written (in one large chunk and 'flushed') to the networkstream and read in smaller chunks (of say 1k).Code:MyStream.EndRead(|parameter|) While MyStream.DataAvailable ByteCount = MyStream.Read(|buffer|, 0, |buffer size|) 'add buffer to data End While 'do something with data MyStream.BeginRead(|parameters|)
This is seriously problematic for the rest of the code, since the information is broken up in bits and not properly handled.
Is there a way to ensure that all data available is 'captured' without using unrealisticly large buffers or using delays?
Regards Tom




Reply With Quote