Exemple #1
0
        public void recvData()
        {
            IPEndPoint ip = new IPEndPoint(IPAddress.Any, 5068);
            Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            newsock.Bind(ip);

            IPEndPoint sender_s = new IPEndPoint(IPAddress.Any, 0);

            while (true)
            {
                udpEventArgs e = new udpEventArgs();
                e.data = new byte[1024];
                EndPoint Remote = (EndPoint)(sender_s);
                e.data = new byte[4096];
                //发送接受信息
                e.recv = newsock.ReceiveFrom(e.data, ref Remote);
                if (owner != null)
                {
                    owner.BeginInvoke(owner.udpEvent, this, e);

                }
            }
        }
Exemple #2
0
 public static void UDPhandler(object sender, udpEventArgs e)
 {
     FormClock bb = new FormClock(800, Encoding.UTF8.GetString(e.data, 0, e.recv));
     bb.Show();
 }