if(client.Available > 0)
{
try
{
byte[] bytes = new byte[18000];
client.GetStream().Read(bytes, 0, bytes.Length);
MemoryStream stream = new MemoryStream(bytes);
stream.Seek(0, SeekOrigin.Begin);
Bitmap bit = new Bitmap(stream);
if (!Shown)
{
Shown = true;
ssViewer.Show();
ssViewer.UpdateImage(bit);
}
stream.Close();
}
catch(Exception ex)
{
PrintToConsole("There was an error in data " + ex.ToString(), ConsoleColor.Red);
MessageBox.Show(ex.ToString());
}
}
So problem is when i do this it gives me error "Parameter is not valid",i think its because there are less bytes in array that it is to read.Is there a way to know how many bytes are there to read from recivedBuffer?