Ejemplo n.º 1
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmUDPClient_Load(object sender, EventArgs e)
        {
            Text = "UDPClient " + _client_id + ":" + _port;

            //注册事件
            UDPClientManager manager = new UDPClientManager(_client_id);
            manager.UDPMessageReceived += new UDPMessageReceivedEventHandler(manager_UDPMessageReceived);
        }
        /// <summary>
        /// 创建客户端
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (UDPClientManager.ClientExist(textBox2.Text))
            {
                MessageBox.Show("客户端已存在!");
                return;
            }
            UDPClientManager manager = new UDPClientManager(textBox2.Text);
            manager.Start(int.Parse(textBox1.Text));  //开启端口监听

            frmUDPClient frmudpclient = new frmUDPClient(textBox2.Text, int.Parse(textBox1.Text));
            frmudpclient.Show();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 发送文本
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click(object sender, EventArgs e)
 {
     UDPClientManager manager = new UDPClientManager(_client_id);
     manager.SendTo(Msg.Zmsg1, Encoding.Unicode.GetBytes(textBox2.Text), textBox4.Text, int.Parse(textBox5.Text));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     UDPClientManager manager = new UDPClientManager(_client_id);
     manager.Stop();
 }