Пример #1
0
        private void button_init_Click(object sender, EventArgs e)
        {
            if (client != null)
            {
                client.Close();
            }
            client = new k.UdpClient("Test".ToCharArray().Select(a => (byte)a).ToArray(), 0, "udppeer".ToCharArray().Select(a => (byte)a).ToArray());

            var arr = textBox_remote.Text.Split(":"[0]);

            remoteipep = new IPEndPoint(IPAddress.Parse(arr[0]), int.Parse(arr[1]));
            client.OnOperationResponse = (buf) =>
            {
                var i = BitConverter.ToInt64(buf, 0);
                //Console.Write($"rec:{i}");
                Task.Run(() =>
                {
                    var snd = i + 1;
                    Console.WriteLine($"udp snd:{snd}");
                    client.SendOperationRequest(BitConverter.GetBytes(snd));
                }
                         );
            };
            client.OnConnected = (sid) =>
            {
                this.Invoke(
                    new Action(() =>
                {
                    this.Text = sid.ToString();
                })
                    );
            };

            client.Connect(remoteipep, true);
        }
Пример #2
0
 private void button_Send_Click(object sender, EventArgs e)
 {
     client?.SendOperationRequest(MakeBigBuff());
 }
Пример #3
0
 private void button_send_Click(object sender, EventArgs e)
 {
     client?.SendOperationRequest(BitConverter.GetBytes((UInt64)1));
 }