Exemplo n.º 1
0
 private void Ts_Init()
 {
     foreach (var item in Service.ServiceBussiness.RtuList)
     {
         TcpSocket ts = new TcpSocket();
         ts.STCD = item.STCD;
         Ts.Add(ts);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 添加socket对象
        /// </summary>
        /// <param name="TS">tcp服务</param>
        /// <param name="socket">socket对象</param>
        public static void AddSocket(TcpServer TS, Socket socket)
        {
            List <TcpSocket> Ts = TS.Ts;

            lock (Ts)
            {
                var temp  = from t in Ts where t.TCPSOCKET == socket select t;
                int count = temp.Count <TcpSocket>();
                if (count == 0)
                {
                    //添加
                    TcpSocket ts = new TcpSocket();
                    ts.CONNECTTIME = DateTime.Now;
                    ts.TCPSOCKET   = socket;
                    Ts.Add(ts);
                }
            }
        }