Socket通信

  Socket命令发送 Socket通信
        public void LostLicense(LicenseInfo license)
        {
            var arr = Dao.QueryForList<Hashtable>(Dao.GetStatementName("LostLicense"), license);
            string socketIpPort = ConfigurationManager.AppSettings["socketIpPort"];
            if (arr != null && socketIpPort != null)
            {
                string[] strIp = socketIpPort.Split(':');
                IPAddress ip = IPAddress.Parse(strIp[0]);
                int port = int.Parse(strIp[1]);
                foreach (var i in arr)
                {
                    Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    clientSocket.Connect(new IPEndPoint(ip, port));
                    var s = Convert.ToString(int.Parse(i["MNGINSID"].ToString()), 16).PadLeft(10, '0');
                    clientSocket.Send(HexStrTobyte("3C09" + s + "39FF"));
                    clientSocket.Close();
                }
            }
        }
View Code

 

上一篇:Python UDP和TCP套接字简单创建和连接


下一篇:Python TCP socket编程