Пример #1
0
        /// <summary>
        /// 发送扫描设备的数据
        /// </summary>
        public void SendCheckInfo()
        {
            string mac = GetLocalMacAddr.GetMacAddr();  //获取本机MAC地址

            //Console.WriteLine("local mac is {0}", mac);

            byte[] head = { 0x0f, 0x0e, 0x0d };   //自定义数据包包头
            byte[] body = Encoding.ASCII.GetBytes(mac + "!");
            byte[] data = head.Concat(body).ToArray();

            UdpClient  client      = null;
            IPAddress  remoteIP    = IPAddress.Parse(devform.getDev_IP());
            int        remotePort  = devform.getDev_port();
            IPEndPoint remotePoint = new IPEndPoint(remoteIP, remotePort);

            client = new UdpClient();
#if debug
            Console.WriteLine("start sending:");
#endif
            client.Send(data, data.Length, remotePoint);
            client.Close();
#if debug
            Console.WriteLine("send successfully!");
#endif
        }
Пример #2
0
        /// <summary>
        /// 发送扫描设备的数据
        /// </summary>
        public void SendCheckInfo()
        {
            //string mac = "40-8D-5C-08-53-A7";
            string mac = GetLocalMacAddr.GetMacAddr();  //获取本机MAC地址
            //Console.WriteLine("local mac is {0}", mac);
            string str = mac + "*";

            //string key = "0123456789ABCDEF0123456789ABCDEF";
            //string iv = "1234567890ABCDEF";
            //// string secret = EncryptDES(str,key);//数据加密
            //byte[] text = Encoding.UTF8.GetBytes(str);
            //byte[] secret = AESEncrypt(text, key, iv);
            //byte[] reverse = AESDecrypt(secret, key, iv);
            byte[] head = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a };   //自定义数据包包头
            byte[] body = Encoding.ASCII.GetBytes(str);
            byte[] data = head.Concat(body).ToArray();

            UdpClient  client      = null;
            IPAddress  remoteIP    = IPAddress.Parse(devform.getDev_IP());
            int        remotePort  = devform.getDev_port();
            IPEndPoint remotePoint = new IPEndPoint(remoteIP, remotePort);

            client = new UdpClient();
#if debug
            Console.WriteLine("start sending:");
#endif
            client.Send(data, data.Length, remotePoint);
            client.Close();
#if debug
            Console.WriteLine("send successfully!");
#endif
        }