المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : NetworkStream, possibly Read timeout?



C# Programming
08-12-2009, 10:54 AM
I have these two applications, one of which sends a screenshot image to the other. This works smoothly on most PCs, however some (older) PCs start receiving a lot of zeros after reading some of the data. How can I ensure that all the data being sent, is read? I don't know if this is a timeout issue, or what?

(I have found some solutions, such as WriteByte / ReadByte, but I need it to perform quite fast too, if possible)

The methods are as follows:

Sending:
if (nsStream.CanWrite)
nsStream.Write(bUp, 0, bUp.Length);

nsStream.Flush();

int x = 0;

while (nsStream.DataAvailable && x <span class="code-keyword">