Beispiel #1
0
 private void startServ()
 {
     while (run)
     {
         counter++;
         bool exception = false;
         try
         {
             clientSocket = ServeurSocket.AcceptTcpClient();
         }catch (Exception e)
         {
             exception = true;
         }
         if (!exception)
         {
             message(">> Client connected N " + counter.ToString());
             //info.AppendText(">> client connected");
             //handleClinet client = new handleClinet();
             //client.startClient(info, clientSocket, counter.ToString());
             Thread temp = new Thread(communication);
             temp.Start();
             tableau.Add(temp);
         }
         //communication();
     }
     if (clientSocket != null)
     {
         clientSocket.Close();
     }
 }
Beispiel #2
0
        public void start()
        {
            run = true;

            // clientSocket = default(TcpClient);

            ServeurSocket.Start();
            counter = 0;

            this.message(">> Serveur Start\n");
            tableau = new List <Thread>();

            ctThread = new Thread(startServ);
            ctThread.Start();

            ctNettoyage = new Thread(clearThread);
            ctNettoyage.Start();
        }
Beispiel #3
0
        public void stop()
        {
            try {
                run = false;
                if (tableau != null)
                {
                    foreach (Thread tpt in tableau)
                    {
                        /*while (!tpt.IsAlive) ;
                         * Thread.Sleep(1);*/
                        tpt.Join();
                    }
                }
                if (ServeurSocket != null)
                {
                    ServeurSocket.Stop();
                }
                //ServeurSocket.Stop();

                /*while (!ctThread.IsAlive) ;
                 * Thread.Sleep(1);
                 * ctThread.Abort();
                 * ctNettoyage.Abort();*/
                /* ctThread.Join();
                 * while (! ctNettoyage.IsAlive) ;
                 * Thread.Sleep(1);
                 *
                 * ctNettoyage.Join();*/
                // ctThread.Abort();
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message, e.Message);
            }
            message(">> Serveur Stop\n");
        }
Beispiel #4
0
 public void stopThreadTcp()
 {
     run = false;
     ServeurSocket.Stop();
 }