Thread th_main,th_sub; bool bool_Start_subTH; Socket Socket_Client ; TcpListener objListener;
private void Form1_Load(object sender, EventArgs e) { bool_Start_subTH=false; th_main = new Thread(GetDataFromClient); th_main.Start(); } void GetDataFromClient() { objListener = new TcpListener(5000); objListener.Start(); while (th_main.IsAlive) { Socket_Client= objListener.AcceptSocket(); if(!bool_Start_subTH) { th_sub=new Thread (SubFunctionThread); th_sub.start(); bool_Start_subTH=false; } } } void SubFunctionThread() { while(th_sub.IsAlive) { if(Socket_Client.Avilable>0) { byte[] something = new byte[Socket_Client.Available]; Socket_Client.Receive(something); string strmessage = Encoding.ASCII.GetString(something); Listbox1.Items.Add( strmessage); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)