Beispiel #1
0
 /// <summary>
 ///   查找服务器
 /// </summary>
 public bool Sendmore(byte[] data)
 {
     using (UdpClient myClient = new UdpClient(3671))
     {
         try
         {
             UDPReceive.ClearQueueData();
             myClient.Send(data, data.Length, ipep);
             myClient.Close();
             return(true);
         }
         catch
         {
             myClient.Close();
             return(false);
         }
     }
 }
Beispiel #2
0
        private static void row_OnPacketArrival(object sender, RowSocket.PacketArrivedEventArgs e)
        {
            try
            {
                if (e.Protocol == "UDP")
                {
                    if (e.OriginationAddress == "192.168.1.106" && e.OriginationPort == "3671" && e.DestinationAddress == "224.0.23.12")
                    {
                        byte[] buf = new byte[e.MessageBuffer.Length - 8];
                        Array.Copy(e.MessageBuffer, 8, buf, 0, e.MessageBuffer.Length - 8);
                        receiveBuff.Enqueue(buf);



                        //Sitems.dstAddress = Convert.ToString(buf[8].ToString() + '.' + buf[9].ToString() + '.' + buf[10].ToString() + '.' + buf[11].ToString());
                        //Sitems.SrcAddress = Convert.ToString(buf[28].ToString() + '.' + buf[29].ToString() + '.' + buf[30].ToString() + '.' + buf[31].ToString());
                        //Sitems.StrMessage = Convert.ToString(buf[32].ToString() + ',' + buf[33].ToString() + ',' + buf[34].ToString() + ',' + buf[35].ToString());
                        //byte[] data = GlobalClass.HexToByte(buf.ToString());

                        //sbuf = Encoding.UTF8.GetString(buf);
                        //Sitems = ReadAppLoadListssJson(sbuf);
                        //Sitems.SrcAddress = e.OriginationAddress;
                        //Sitems.dstAddress = e.DestinationAddress;
                    }
                    if (e.DestinationAddress == "224.0.23.12" && e.OriginationPort == "3671" &&
                        e.OriginationAddress != GetLocalIP())
                    {
                        byte[] buffer = new byte[e.MessageBuffer.Length - 8];
                        Array.Copy(e.MessageBuffer, 8, buffer, 0, e.MessageBuffer.Length - 8);

                        UDPReceive.OnReceive(buffer);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            //throw new Exception("The method or operation is not implemented.");
        }