コード例 #1
0
        public void SetTime (UdpClient client)
        {
            
            var centralPointIp = ConfigurationManager.AppSettings[AppKeys.CentralUnitIpAddress];

            IPAddress serverAddr = IPAddress.Parse("192.168.0.100");
            // IPAddress serverAddr = IPAddress.Parse("127.0.0.1");

            IPEndPoint endPoint = new IPEndPoint(serverAddr, 9992);

            ParserHelper parserHelper = new ParserHelper();
            string time = parserHelper.DatetimeToUnixTimeStamp(DateTime.Now);
            //  string text = "SET_TIME " +time;
            
            string text = "x02SET_TIME 1466697715\x0D";
            byte[] send_buffer = Encoding.ASCII.GetBytes(text);

            client.Send(send_buffer, send_buffer.Length, endPoint);
        }
コード例 #2
0
        //public void StartConversation()
        //{
           
        //}


        public void StartConversation()
        {
            using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
            {
                var centralPointIp = ConfigurationManager.AppSettings[AppKeys.CentralUnitIpAddress];

                IPAddress serverAddr = IPAddress.Parse(centralPointIp);
                // IPAddress serverAddr = IPAddress.Parse("127.0.0.1");

                IPEndPoint endPoint = new IPEndPoint(serverAddr, 9992);

                ParserHelper parserHelper = new ParserHelper();
                string text = "blablaloclatest";
                byte[] send_buffer = Encoding.ASCII.GetBytes(text);

                socket.SendTo(send_buffer, endPoint);
          //      socket.Disconnect(true);
                socket.Close();
            }
            

            
        }
コード例 #3
0
        public void StartConversation2 (UdpClient client)
        {
           
                var centralPointIp = ConfigurationManager.AppSettings[AppKeys.CentralUnitIpAddress];

                IPAddress serverAddr = IPAddress.Parse("192.168.0.100");
                // IPAddress serverAddr = IPAddress.Parse("127.0.0.1");

                IPEndPoint endPoint = new IPEndPoint(serverAddr, 9992);

                ParserHelper parserHelper = new ParserHelper();
                string text = "x02SET_TIME 1466695973\x0D";
                byte[] send_buffer = Encoding.ASCII.GetBytes(text);

                client.Send(send_buffer, send_buffer.Length, endPoint);
                //      socket.Disconnect(true);
                
               
            
        }