this.Invoke(new Action<string>(AppendTxtdata), new object[] { myval });
public void startClient(TcpClient inClientSocket, string clineNo)
{
this.clientSocket = inClientSocket;
inClientSocket.NoDelay = true;
this.clNo = clineNo;
new Thread(GetData).Start();
}
public void GetData() // to run server //
{
con.Open();
this.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);