class Listener{ Thread listenThread; Socket listenSocket; bool isListeningContinued=false; public Listener(){ listenSocket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); listenThread=new Thread(new ThreadStart(Listening)); } public void Start(IPEndPoint ipEP){ listenSocket.Bind(ipEP); listenSocket.Listen(100); isListeningContinued=true; listenThread.Start(); } public void Stop(){ isListeningContinued=false; listenSocket.ShutDown(SocketShutdown.Both); listenSocket.Close(); } void Listening(){ while(isListeningContinued){ Socket socket=listenSocket.Accept(); //Do something to receive the data from client } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)