Log() 공개 메소드

public Log ( string s ) : void
s string
리턴 void
예제 #1
0
 /// <summary>
 /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
 /// </summary>
 public void Run()
 {
     tcpListener_.Start();
     while (State.RUNNING == ReactorState)
     {
         try
         {
             TcpClient client = tcpListener_.AcceptTcpClient();
             ApplySocketOptions(client);
             ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++);
             lock (sync_)
             {
                 clientThreads_.AddLast(t);
             }
             // FIXME set the client thread's exception handler here
             t.Log("connected");
             t.Start();
         }
         catch (System.Exception e)
         {
             if (State.RUNNING == ReactorState)
                 this.Log("Error accepting connection: " + e.Message);
         }
     }
     ShutdownClientHandlerThreads();
 }
 /// <summary>
 /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
 /// </summary>
 public void Run()
 {
     tcpListener_.Start();
     while (State.RUNNING == ReactorState)
     {
         try
         {
             TcpClient client = tcpListener_.AcceptTcpClient();
             ApplySocketOptions(client, socketSettings_);
             ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++);
             lock (sync_)
             {
                 clientThreads_.AddLast(t);
             }
             // FIXME set the client thread's exception handler here
             t.Log("connected");
             t.Start();
         }
         catch (System.Exception e)
         {
             if (State.RUNNING == ReactorState)
             {
                 this.Log("Error accepting connection: " + e.Message);
             }
         }
     }
     ShutdownClientHandlerThreads();
 }
 private void ShutdownClientHandlerThreads()
 {
     lock (sync_)
     {
         if (State.SHUTDOWN_COMPLETE != state_)
         {
             this.Log("shutting down...");
             while (clientThreads_.Count > 0)
             {
                 ClientHandlerThread t = clientThreads_.First.Value;
                 clientThreads_.RemoveFirst();
                 t.Shutdown("reactor is shutting down");
                 try
                 {
                     t.Join();
                 }
                 catch (System.Exception e)
                 {
                     t.Log("Error shutting down: " + e.Message);
                 }
             }
             state_ = State.SHUTDOWN_COMPLETE;
         }
     }
 }
예제 #4
0
        /// <summary>
        /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
        /// </summary>
        public void Run()
        {
            lock (sync_)
            {
                if (State.SHUTDOWN_REQUESTED != state_)
                {
                    try
                    {
                        tcpListener_.Start();
                    }
                    catch (Exception e)
                    {
                        this.Log("Error starting listener: " + e.Message);
                        throw;
                    }
                }
            }

            while (State.RUNNING == ReactorState)
            {
                try
                {
                    TcpClient client = tcpListener_.AcceptTcpClient();
                    if (State.RUNNING == ReactorState)
                    {
                        ApplySocketOptions(client, socketSettings_);
                        ClientHandlerThread t =
                            new ClientHandlerThread(client, nextClientId_++, sessionDict_, socketSettings_, acceptorDescriptor_);
                        t.Exited += OnClientHandlerThreadExited;
                        lock (sync_)
                        {
                            clientThreads_.Add(t.Id, t);
                        }

                        // FIXME set the client thread's exception handler here
                        t.Log("connected");
                        t.Start();
                    }
                    else
                    {
                        client.Dispose();
                    }
                }
                catch (System.Exception e)
                {
                    if (State.RUNNING == ReactorState)
                    {
                        this.Log("Error accepting connection: " + e.Message);
                    }
                }
            }
            tcpListener_.Server.Close();
            tcpListener_.Stop();
            ShutdownClientHandlerThreads();
        }
예제 #5
0
        /// <summary>
        /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
        /// </summary>
        public void Run()
        {
            lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable)
            {
                if (State.SHUTDOWN_REQUESTED != state_)
                {
                    tcpListener_.Start();
                }
            }

            while (State.RUNNING == ReactorState)
            {
                try
                {
                    TcpClient client = tcpListener_.AcceptTcpClient();
                    ApplySocketOptions(client, socketSettings_);
                    ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++, sessionDict_, socketSettings_);
                    t.Exited += OnClientHandlerThreadExited;
                    lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable)
                    {
                        clientThreads_.Add(t.Id, t);
                    }
                    // FIXME set the client thread's exception handler here
                    t.Log("connected");
                    t.Start();
                }
                catch (System.Exception e)
                {
                    if (State.RUNNING == ReactorState)
                    {
                        this.Log("Error accepting connection: " + e.Message);
                    }
                }
            }
            ShutdownClientHandlerThreads();
        }
예제 #6
0
 /// <summary>
 /// FIXME do proper logging
 /// </summary>
 /// <param name="s"></param>
 private void Log(string s)
 {
     responder_.Log(s);
 }
예제 #7
0
        /// <summary>
        /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
        /// </summary>
        public void Run()
        {
            lock (sync_)
            {
                if (State.SHUTDOWN_REQUESTED != state_)
                {
                    try
                    {
                        tcpListener_.Start();
                    }
                    catch (Exception e)
                    {
                        this.Log("Error starting listener: " + e.Message);
                        throw;
                    }
                }
            }

            while (State.RUNNING == ReactorState)
            {
                try
                {
                    TcpClient client = tcpListener_.AcceptTcpClient();
                    if (socketSettings_.SocketCountPerHost.HasValue)
                    {
                        var address = ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString();
                        lock (sync_)
                        {
                            if (clientThreads_.Values.Count(c => c.SourceAddress == address) >= socketSettings_.SocketCountPerHost)
                            {
                                client.Dispose();
                                Log($"Limit of connections per host was reached for '{address}'");
                                continue;
                            }
                        }
                    }


                    if (State.RUNNING == ReactorState)
                    {
                        ApplySocketOptions(client, socketSettings_);
                        ClientHandlerThread t =
                            new ClientHandlerThread(client, nextClientId_++, sessionDict_, socketSettings_, acceptorDescriptor_);
                        t.Exited += OnClientHandlerThreadExited;
                        lock (sync_)
                        {
                            clientThreads_.Add(t.Id, t);
                        }

                        // FIXME set the client thread's exception handler here
                        t.Log("connected");
                        t.Start();
                    }
                    else
                    {
                        client.Dispose();
                    }
                }
                catch (System.Exception e)
                {
                    if (State.RUNNING == ReactorState)
                    {
                        this.Log("Error accepting connection: " + e.Message);
                    }
                }
            }
            tcpListener_.Server.Close();
            tcpListener_.Stop();
            ShutdownClientHandlerThreads();
        }
        /// <summary>
        /// TODO apply networking options, e.g. NO DELAY, LINGER, etc.
        /// </summary>
        public void Run()
        {
            lock (sync_)
            {
                if (State.SHUTDOWN_REQUESTED != state_)
                    tcpListener_.Start();
            }

            while (State.RUNNING == ReactorState)
            {
                try
                {
                    TcpClient client = tcpListener_.AcceptTcpClient();
                    ApplySocketOptions(client, socketSettings_);
                    ClientHandlerThread t = new ClientHandlerThread(client, nextClientId_++, sessionDict_, socketSettings_);
                    t.Exited += OnClientHandlerThreadExited;
                    lock (sync_)
                    {
                        clientThreads_.Add(t.Id, t);
                    }
                    // FIXME set the client thread's exception handler here
                    t.Log("connected");
                    t.Start();
                }
                catch (System.Exception e)
                {
                    if (State.RUNNING == ReactorState)
                        this.Log("Error accepting connection: " + e.Message);
                }
            }
            ShutdownClientHandlerThreads();
        }