NetworkStream, possibly Read timeout?
-
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 < dataReadWait)
{
x++;
// Wait for data to be read
}return true;
Receiving:
if (nsStream.CanRead)
nsStream.Read(bDown, 0, bDown.Length);nsStream.Flush();
return bDown;At this point, it is worth saying that the Sender prior to sending the actual image, sends the length of the image (which is assigned to bDown), that is why data is read until the length of bDown... Any help is so greatly appreciated!