/* Wait for connections - threading function */ public void ListenForClients() { while (true) { Console.WriteLine("Waiting for a new connection..."); //blocks until a client connects to the server try { TcpListener.Start(); } catch (SocketException) //if socket is invalid { throw; } //create new socket Sock = TcpListener.AcceptSocket(); //ClientComm-class is responsible for receiving sentences CComm = new ClientComm(Sock); /* create a thread to handle communication with connected client */ ClientThread = new Thread(new ThreadStart(CComm.WelcomeClient)); try { ClientThread.Start(); } catch (Exception) { throw; //throw to main } } }
/* Wait for connections - threading function */ public void ListenForClients() { while(true) { Console.WriteLine("Waiting for a new connection..."); //blocks until a client connects to the server try { TcpListener.Start(); } catch (SocketException) //if socket is invalid { throw; } //create new socket Sock = TcpListener.AcceptSocket(); //ClientComm-class is responsible for receiving sentences CComm = new ClientComm(Sock); /* create a thread to handle communication with connected client */ ClientThread = new Thread(new ThreadStart(CComm.WelcomeClient)); try { ClientThread.Start(); } catch (Exception) { throw; //throw to main } } }