0

I'm building a windows service in C# to work as a server, I first built it as a regular application and it works like a charm, but when I transferred it to the service I get no connections, everything seems to be set up fine. But when I connect I get nothing, no event is triggered... Is there a difference that I need to keep in mind?

/Nick

public void start()
    {
            try
            {

                int port = DEFAULT_PORT;
                Int32 numConnections = DEFAULT_NUM_CONNECTIONS;
                Int32 bufferSize = DEFAULT_BUFFER_SIZE;

                SocketListener sl = new SocketListener(numConnections, bufferSize, parent);

                sl.Start(port); 

                Console.WriteLine("Server listening on port {0}. Press any key to terminate the server process...", port);
                Console.Read();

                sl.Stop();

            }

            catch (Exception ex)
            {
                parent.logger.WriteLogg(ex.ToString(), Logger.LoggType.Debug);
            }

    }
4

1 回答 1

0

由于该服务不执行 Console.Write/Read 所以在服务中我关闭了 SocketListener 但在应用程序中它停止在 Console.Read()

于 2012-09-04T06:18:50.513 回答