コード例 #1
0
ファイル: Program.cs プロジェクト: radtek/SocketServer
        protected void ServerThread()
        {
            listener.Initialize(4000);
            listener.Start();

            Logger.InfoFormat("Server started and listening on port {0}", 4000);

            running = true;

            while (!stopEvent.WaitOne(100))
            {
                INetworkTransport transport = listener.AcceptClient();
                if (transport != null)
                {
                    // let's wrap this with a client connection
                    ClientConnection connection = ClientConnection.CreateClientConnection(new PlainEnvelope(), transport);

                    // start pumping messages on this connection
                    //connection.StartMessagePump();

                    connection.MessageReceived += new EventHandler <MessageEventArgs>(connection_MessageReceived);

                    // add to client list
                    AddClient(connection);
                }
            }

            listener.Stop();
        }