コード例 #1
0
        private void Do()
        {
            Task.Factory.StartNew(() =>
            {
                List <int> ports = CMDNetstatTool.GetAvailablePorts(10, 52810);
                if (Ls.Ok(ports))
                {
                    foreach (var p in ports)
                    {
                        try
                        {
                            R.Tx.TcppPort   = p;
                            R.Tx.TcppServer = new TcppServer(R.Tx.TcppPort, TcppEvent.ReceiveMessage,
                                                             TcppEvent.OnConnect, TcppEvent.OnDisconnect);
                            R.Tx.TcppServer.Start();//启动 Socket Tcp 通信机制
                            IniTool.Set(R.Files.Settings, "Tx", "TcppPort", R.Tx.TcppPort);
                            IniTool.Set(R.Files.Settings, "Tx", "StartTime", DateTime.Now.ToString());
                            break;
                        }
                        catch { }
                    }
                }

                R.USBListener.Start();        // 启动USB监控
                R.USBStorageListener.Start(); // 启动U盘监控
            });
        }
コード例 #2
0
        static void Main()
        {
            byte[] bt   = Json.Object2Byte("测试 Json Byte 转换");
            string __bt = Json.Byte2Object <string>(bt);

            byte[] a   = Encoding.UTF8.GetBytes("张无忌");
            string __a = Encoding.UTF8.GetString(a);

            byte[] b   = Encoding.Unicode.GetBytes("张无忌");
            string __b = Encoding.Unicode.GetString(b);

            byte[] c   = Encoding.UTF8.GetBytes("ぬゆまほㅙㅚЪЖ");
            string __c = Encoding.UTF8.GetString(c);

            byte[] d   = Encoding.Unicode.GetBytes("ぬゆまほㅙㅚЪЖ");
            string __d = Encoding.Unicode.GetString(d);


            List <int> ports = CMDNetstatTool.GetAvailablePorts(10);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
コード例 #3
0
 public static void Start()
 {
     Task.Factory.StartNew(() =>
     {
         List <int> ports = CMDNetstatTool.GetAvailablePorts(10, 52830);
         if (Ls.Ok(ports))
         {
             foreach (var p in ports)
             {
                 try
                 {
                     R.Tx.Port       = p;
                     R.Tx.TcppServer = new TcppServer(R.Tx.Port, ReceiveMessage,
                                                      OnConnect, OnDisconnect);
                     R.Tx.TcppServer.Start();//启动 Socket Tcp 通信机制
                     break;
                 }
                 catch { }
             }
         }
     });
 }