예제 #1
0
파일: Form1.cs 프로젝트: wm9947/gochat_team
        private void btn_end_Click(object sender, EventArgs e)
        {
            if (ServerTCPListner != null)
            {
                ServerTCPListner.Stop();
            }

            MessageBox.Show("server ended.!!");

            foreach (Socket SocketStart in HTSocketHolder.Values)
            {
                if (SocketStart.Connected)
                {
                    SocketStart.Close();
                }
            }

            foreach (Thread ThreadStart in HTThreadHolder.Values)
            {
                if (ThreadStart.IsAlive)
                {
                    ThreadStart.Abort();
                }
            }

            Application.Exit();
        }
예제 #2
0
 private void ServerStartbut_Click(object sender, EventArgs e)
 {
     try
     {
         server = SocketStart.startServer(int.Parse(textBox_port.Text));
         server.AcceptString += new EventDelegate <IPEndPoint, string>(acceptString);
         //server.AcceptByte += new EventDelegate<IPEndPoint, byte[]>(acceptBytes);
         server.Connect       += new EventDelegate <IPEndPoint>(connect);
         server.dateSuccess   += new EventDelegate <IPEndPoint>(dateSuccess);
         server.Disconnection += new EventDelegate <IPEndPoint, string>(disconnection);
         server.EngineClose   += new EventDelegate(engineClose);
         server.EngineLost    += new EventDelegate <string>(engineLost);
         //server.BufferSize=12048;
         //server.FileLog = "C:\\test.txt";
         server.StartEngine();
         this.ServerStartbut.Enabled = false;
         this.ServerCloseBut.Enabled = true;
         this.Sendbut.Enabled        = true;
         //  this.button8.Enabled = true;
     }
     catch (Exception Ex) { MessageBox.Show(Ex.Message); }
 }