C# Problems With Sending/Receiving Size of bytes (Sockets)
===

I've made these codes to send and receive an Image with a TCP socket but the receive code didn't work, hope you can help me
this is the Send Code

    public void SendImage()
    {
        int ScreenWidth = Screen.GetBounds(new Point(0, 0)).Width;
        int ScreenHeight = Screen.GetBounds(new Point(0, 0)).Height;
        Bitmap bmpScreenShot = new Bitmap(ScreenWidth, ScreenHeight);
    
    
    
        Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
        gfx.CopyFromScreen(0, 0, 0, 0, new Size(ScreenWidth, ScreenHeight));
        bmpScreenShot.Save(Application.StartupPath + "/ScreenShot.jpg", ImageFormat.Jpeg);
        byte[] image = new byte[1];
        bmpScreenShot = ResizeBitmap(bmpScreenShot, 300, 300);
       
        
        image = ImageToByte(bmpScreenShot);
        //get the length of image (length of bytes)
        int NumberOfBytes = image.Length;
        //put the size into a byte array
        byte[] numberofbytesArray = BitConverter.GetBytes(NumberOfBytes);
    
        //send the size to the Client
       int sizesend = sck.Send(numberofbytesArray, 0, numberofbytesArray.Length, 0);
        if (sizesend > 0)
        {
            MessageBox.Show("Size Sent");
        }
        //send the image to the Client
        int imagesend =sck.Send(image, 0, NumberOfBytes, 0);
        if (imagesend > 0)
        {
            MessageBox.Show("Image Sent");
        }
        
    
    }

And Here is the Receive Code


    public void ReceiveImage()
    {
        
        if (sck.Connected)
        {
            
            {
                NetworkStream stream = new NetworkStream(sck);
                byte[] data = new byte[4];
    
                //Read The Size
                stream.Read(data, 0, data.Length);
                int size = (BitConverter.ToInt32(data,0));
                // prepare buffer
                data = new byte[size];
                
                //Load Image
                int read = 0;
                while (read != data.Length)
                {
                   read += stream.Read(data, read, data.Length - read);
                }
                //stream.Read(data, 0, data.Length);
                //Convert Image Data To Image
                MemoryStream imagestream = new MemoryStream(data);
                Bitmap bmp = new Bitmap(imagestream);
                pictureBox1.Image = bmp;                    
            }
        }
    }

the problem is when i send the size, its sent as 5kb but when i receive it i find it 2GB and this error comes up
`Unable to read data from the transport connection. An operation on a socket could be performed because the system lacked sufficient buffer space or because a queue was full. `

the error is at this statement `read += stream.Read(data, read, data.Length - read);`
