private void button1_Click(object sender, EventArgs e)
 {
     if (this.client == null)
     {
         int myPort = int.Parse(this.textBox1.Text);
         string remoteIP = this.textBox2.Text;
         int remotePort = int.Parse(this.textBox3.Text);
         this.client = new UDP_CLIENT(remoteIP, remotePort, myPort);
         this.client.DataReceived += this.DataReceived;
         this.button1.Text = "disconnect";
     }
     else
     {
         this.client.Close();
         this.button1.Text = "Connect";
     }
 }
Exemple #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.client == null)
     {
         int    myPort     = int.Parse(this.textBox1.Text);
         string remoteIP   = this.textBox2.Text;
         int    remotePort = int.Parse(this.textBox3.Text);
         this.client = new UDP_CLIENT(remoteIP, remotePort, myPort);
         this.client.DataReceived += this.DataReceived;
         this.button1.Text         = "disconnect";
     }
     else
     {
         this.client.Close();
         this.button1.Text = "Connect";
     }
 }
 void MakeNewLocalClient(System.Net.IPEndPoint EP)
 {
     try
     {
         UDP_CLIENT newclient = new UDP_CLIENT(EP.Address.ToString(), this.newclientPort, this.localPort);
         //接続
         this.localClients.Add(newclient);
         //受信開始
         newclient.StartReceive();
         this.makelocalclient(this.newclientPort, this.localPort, EP.Address.ToString());
         this.Send(this.localPort, this.newclientPort);
         this.localPort++;
         this.newclientPort++;
         Console.WriteLine("client");
     }
     catch
     {
         Console.WriteLine("Error:makenewclient");
     }
 }
 void MakeNewLocalClient(System.Net.IPEndPoint EP)
 {
     try
     {
         UDP_CLIENT newclient = new UDP_CLIENT(EP.Address.ToString(), this.newclientPort, this.localPort);
         //接続
         this.localClients.Add(newclient);
         //受信開始
         newclient.StartReceive();
         this.makelocalclient(this.newclientPort, this.localPort, EP.Address.ToString());
         this.Send(this.localPort, this.newclientPort);
         this.localPort++;
         this.newclientPort++;
         Console.WriteLine("client");
     }
     catch
     {
         Console.WriteLine("Error:makenewclient");
     }
 }