public void AppendTxtdata(string val) { try { if (InvokeRequired) { this.Invoke(new Action<string>(AppendTxtdata), new object[] { val }); return; } txtdata.Text += val; } catch { } }
public void GetData() // to run server // { Form1 f = new Form1(); try { NetworkStream networkStream = clientSocket.GetStream(); for (int p = 0; p >= 0; p++) { byte[] b = new byte[100]; int k = networkStream.Read(b, 0, b.Length); f.AppendTxtdata("The Data from Client ( " + clNo + " ) Recieved..." + Environment.NewLine); for (int i = 0; i < k; i++) { f.AppendTxtdata("" + Convert.ToChar(b[i])); } f.AppendTxtdata(Environment.NewLine); var j = b.Length - 1; while (b[j] == 0) { --j; } var temp = new byte[j + 1]; Array.Copy(b, temp, j + 1); string res = System.Text.Encoding.ASCII.GetString(temp); }
txtdata
null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)