Esempio n. 1
0
        void Accept(IAsyncResult result)
        {
            if (shuttingDown)
            {
                return;
            }
            Player p     = null;
            bool   begin = false;

            try
            {
                p = new Player {
                    socket = listen.EndAccept(result)
                };

                new Thread(p.Start).Start();

                listen.BeginAccept(Accept, null);
                begin = true;
            }
            catch (SocketException)
            {
                if (p != null)
                {
                    p.Disconnect();
                }
                if (!begin)
                {
                    listen.BeginAccept(Accept, null);
                }
            }
            catch (Exception e)
            {
                Logger.Log(e.Message);
                Logger.Log(e.StackTrace);
                if (p != null)
                {
                    p.Disconnect();
                }
                if (!begin)
                {
                    listen.BeginAccept(new AsyncCallback(Accept), null);
                }
            }
        }
Esempio n. 2
0
        void Accept(IAsyncResult result)
        {
            if (shuttingDown == false)
            {
                Player p = null;
                bool begin = false;
                try
                {
                    p = new Player();

                        p.socket = listen.EndAccept(result);
                        new Thread(new ThreadStart(p.Start)).Start();

                    listen.BeginAccept(new AsyncCallback(Accept), null);
                    begin = true;
                }
                catch (SocketException e)
                {
                    if (p != null)
                        p.Disconnect();
                    if (!begin)
                        listen.BeginAccept(new AsyncCallback(Accept), null);
                }
                catch (Exception e)
                {
                    Log(e.Message);
                    Log(e.StackTrace);
                    if (p != null)
                        p.Disconnect();
                    if (!begin)
                        listen.BeginAccept(new AsyncCallback(Accept), null);
                }
            }
        }