public frmServer()
        {
            InitializeComponent();
            StartListener();
        } 
        //设端口
        bool done = false;
        private const int listenPort = 11000;
        private  void StartListener()
        {
            UdpClient listener = new UdpClient(listenPort);
            //任意IP,设端口为0表示任意
            IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
            try
            {
                while (!done)
                {
                    byte[] bytes = listener.Receive(ref groupEP);
                    string strIP;
                    strIP ="信息来自"+ groupEP.Address.ToString();
                    string strInfo=Encoding.GetEncoding("gb2312").GetString(bytes, 0, bytes.Length);
                    MessageBox.Show(strInfo, strIP);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                listener.Close();
            }
        }
改成这个public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }        #region//定义变量
        IPAddress HostIP = IPAddress.Parse("127.0.0.1");
        IPEndPoint point;
        Socket socket;
        bool flag = true;
        Socket acceptedSocket;
        #endregion        #region//声名委托
        delegate void SetTextCallback(string text);
        private void SetText(string text)
        {
            textBox2.AppendText(text + "\r\n");
        }
        #endregion        #region//进程方法
        private void Proccess()
        {
            if (acceptedSocket.Connected)
            {
                while (flag)
                {
                    byte[] receiveByte = new byte[64];
                    acceptedSocket.Receive(receiveByte, receiveByte.Length, 0);
                    string strInfo = Encoding.BigEndianUnicode.GetString(receiveByte);
                    this.Invoke(new SetTextCallback(SetText), new object[] { strInfo });                }
            }
        }
        #endregion        private void button3_Click(object sender, EventArgs e)
        {
            socket.Close();
            acceptedSocket.Close();
        }        private void button2_Click_1(object sender, EventArgs e)
        {
            try
            {
                Byte[] sendByte = new Byte[64];
                string sendStr = this.textBox1.Text + ":" + this.textBox3.Text + "\r\n";
                sendByte = Encoding.BigEndianUnicode.GetBytes(sendStr.ToCharArray());
                acceptedSocket.Send(sendByte, sendByte.Length, 0);
            }
            catch { }
        }        private void button1_Click_1(object sender, EventArgs e)
        {
            HostIP = IPAddress.Parse("127.0.0.1");
            try
            {
                point = new IPEndPoint(HostIP, Int32.Parse("11000"));
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Bind(point);
                socket.Listen(50);
                acceptedSocket = socket.Accept();
                Thread thread = new Thread(new ThreadStart(Proccess));
                thread.Start();
            }
            catch (Exception ey)
            {
                MessageBox.Show(ey.Message);
            }
        }
也 是 程序无法响应.....