private int read(IVNC_Socket n, byte[] buffer) { if (n.Available) { if ((DateTime.Now - Second_Counter).TotalMilliseconds > 1000) { Second_Counter = DateTime.Now; _ThroughPut = 0; } Last_Time_Heard = DateTime.Now; var t = n.read(buffer); _ThroughPut += t; _Total_Data_Transfered += t; return(t); } return(0); }
//parses the id portion of what the host sends back and extracts it private int GetID(IVNC_Socket h) { int maxiterations = 0; while (!h.Available && maxiterations++ < 5) { System.Threading.Thread.Sleep(100); } // wait for response var bytes = new byte[250]; var i = h.read(bytes); if (i > 0) { return(Utility.ParseID(System.Text.Encoding.UTF8.GetString(bytes, 0, i))); } return(-1);//return an invalid id }