I'm building a client/server solution which needs to have screen sharing functionality. I have something already "working" but the problem is that it only works over internal network, because my methodology is not fast enough.
What I am basically doing is that the client makes a request for the server asking for a screen image each 5 seconds (for example). And this is the code which is processed once this requests are received:
private void GetImage(object networkstream)
{
NetworkStream network = (NetworkStream)networkstream;
Bitmap bitmap = new Bitmap(
SystemInformation.PrimaryMonitorSize.Width,
SystemInformation.PrimaryMonitorSize.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), bitmap.Size);
g.Flush();
g.Dispose();
MemoryStream ms = new MemoryStream();
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
byte[] array = ms.ToArray();
network.Write(array, 0, array.Length);
network.Flush();
ms.Dispose();
}
What are best methods to do what I'm trying to? I need to get at least 0.2 FPS (refresh each 5 seconds) Obs.: I'm using Windows Forms and it is being done over sockets.
How do TeamViwer and .rdp files work?