Beispiel #1
0
        public void Init_IP_right_or_not(byte[] array_byte_tt, UInt16 port_tt, byte[] NBIoT_IP_Byte_Array, UInt16 NBIoT_DuanKou,
                                         ref UDP_Communication mysql_Thread_tt)
        {
            Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            try
            {
                IPAddress ip = new IPAddress(array_byte_tt);
                newsock.Bind(new IPEndPoint(ip, port_tt));//设定ip地址及端口号
            }
            catch
            {
                MessageBox.Show("本机ip地址配置出错", "error");
                Application.Current.Shutdown();
            }

            try
            {
                Init_NBIoT(NBIoT_IP_Byte_Array, NBIoT_DuanKou, ref mysql_Thread_tt);//将NBIoT的远程地址绑定在相应的"UDP_Communication"类里,并发送第一个注册码
            }
            catch
            {
                MessageBox.Show("远程ip地址配置出错", "error");
                Application.Current.Shutdown();
            }
            newsock.Dispose();//消除此套接字,因为此套接字只是用于检测
        }
 public void FixedUpdate()
 {
     if (portserie != null)
     {
         while (portserie.InputBuffer.Count > 0)
         {
             ReadTrame();
         }
     }
     else
     {
         portserie = GetComponent <UDP_Communication>();
     }
 }
Beispiel #3
0
        public void Init_NBIoT(byte[] NBIoT_IP_Byte_Array_tt, ushort NBIoT_DuanKou_tt, ref UDP_Communication mysql_Thread_tt)
        {
            string temp_str = "ep=J4JFAJUGYS3GGF7Z&pw=123456";

            byte[] buff = System.Text.Encoding.ASCII.GetBytes(temp_str);

            byte[]     array_byte = NBIoT_IP_Byte_Array_tt;//设定远程ip地址
            IPAddress  ip         = new IPAddress(array_byte);
            IPEndPoint lep        = new IPEndPoint(ip, NBIoT_DuanKou_tt);

            mysql_Thread_tt.newsock.Connect(lep);
            mysql_Thread_tt.newsock.Send(buff);
        }