TCP IP Listener in windows Service
问题 I'm trying to create a windows service that needs to run in the background and listen for incoming traffic (a normal and regular TCP listener) my code is: private TcpListener server; public void startServer() { // EventLog.WriteEntry(source, "connected on: " + ipAddress.ToString() + " port: " + Service1.Port.ToString()); server = new TcpListener(IPAddress.Parse("127.0.0.1"), Service1.Port); server.Start(); while (true) { var client = server.AcceptTcpClient(); new Thread(work).Start(client); }