Example #1
0
 /** フォームを閉じる*/
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     // TCPを閉じる
     if (tcpServer != null)
     {
         tcpServer.closeTcpListener();
         tcpServer = null;
     }
 }
Example #2
0
        /** 開始*/
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "開始")
            {
                // UDP起動
                udp = new UdpClient(SERVER_PORT);
                udp.DontFragment = true;    // 断片化を防ぐ
                udp.EnableBroadcast = true; // ブロードキャスト許可

                // 受信を開始
                udp.BeginReceive(new AsyncCallback(ReceiveCallback), udp);

                // ボタン変更
                button1.Text = "再送";

                // ポーリングの開始
                timer1.Enabled = true;

                // TCP開始
                if (tcpServer == null)
                {
                    tcpServer = new TcpServer();
                    tcpServer.StartServer(textBox2);
                }
            }

            // 送信実行
            sendCall();
        }