public void Start() { TcpListener server = null; try { // Set the TcpListener on port 13000. Int32 port = 9999; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); // TcpListener server = new TcpListener(port); server = new TcpListener(localAddr, port); // Start listening for client requests. server.Start(); // Matchmacking thread BackgroundWorker matchmacking = new BackgroundWorker(); matchmacking.WorkerReportsProgress = true; matchmacking.DoWork += new DoWorkEventHandler(MatchMaker.Match); matchmacking.ProgressChanged += new ProgressChangedEventHandler(MatchMaker.FoundMatch); matchmacking.RunWorkerAsync(); // Enter the listening loop. while (true) { Console.WriteLine("Waiting for a connection... "); // Perform a blocking call to accept requests. // You could also user server.AcceptSocket() here. TcpClient client = server.AcceptTcpClient(); // Start new Thread to handle Console.WriteLine("New Client Connected!"); Thread qq = new Thread(() => MatchMaker.AppendClient(client)); qq.Start(); qq.Join(); MyTcpListener.connections.Add(qq); } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); }