Beispiel #1
0
        static void noserver_thread(object o)
        {
            XPloitSocket       cs = (XPloitSocket)o;
            XPloitSocketClient c  = cs._Client;
            bool checkTimeOut     = cs._TimeOut != TimeSpan.Zero;

            try
            {
                while (!cs._IsStopping && c.IsConnected)
                {
                    //lectura sincrona en este hilo
                    if (!cs.Read(c) && checkTimeOut && c.HasTimeOut)
                    {
                        if (DateTime.Now - c.LastRead > cs._TimeOut && !cs.RaiseOnTimeOut(c))
                        {
                            c.Disconnect(EDissconnectReason.TimeOut);
                            break;
                        }
                    }
                    Thread.Sleep(0);
                }
            }
            catch { }

            cs.Remove(c, c.DisconnectReason);
            cs.Stop(true);
        }
Beispiel #2
0
        static void server_thread(object o)
        {
            XPloitSocket cs   = (XPloitSocket)o;
            DateTime     time = DateTime.Now;

            bool          check_time_out = cs._TimeOut != TimeSpan.Zero;
            AsyncCallback callme         = new AsyncCallback(cs.socket_acept);

            cs._Server.BeginAccept(callme, cs);

            while (!cs._IsStopping)
            {
                //lock (cs._Clients) ya hace el lock el añadido
                //{
                for (int x = cs._Clients.Length - 1; x >= 0; x--)
                {
                    XPloitSocketClient c = cs._Clients[x];

                    //lectura sincrona en este hilo
                    if (!cs.Read(c) && check_time_out && c.HasTimeOut)
                    {
                        if (DateTime.Now - c.LastRead > cs._TimeOut && !cs.RaiseOnTimeOut(c))
                        {
                            cs.Remove(c, EDissconnectReason.TimeOut);
                            continue;
                        }
                    }

                    if (!c.IsConnected)
                    {
                        cs.Remove(c, c.DisconnectReason);
                    }
                    //}
                }
                Thread.Sleep(0);
            }
        }