public void Run() { try { _service = new iRacingComm(); Int32 port = ServerPort; IPAddress localAddr = IPAddress.Parse(ServerAddress); _server = new TcpListener(localAddr, port); _server.Start(); while (true) { OnTcpServerMessage("TcpServer listening for incoming connections..."); TcpClient client = _server.AcceptTcpClient(); HandleIncomingConnection(client); } } catch (SocketException ex) { if (ex.HResult != -2147467259) { OnTcpServerError(ex); } } catch (Exception ex) { OnTcpServerError(ex); } finally { OnTcpServerMessage("TcpServer is closing the listening socket!"); _server.Stop(); } }