Beispiel #1
0
 /// <summary>
 /// 单例模式,构造函数声明为私有
 /// </summary>
 private PhyPortManager()
 {
     for (int i = 0; i < Const.MAX_DEVICE_NUM + 1; i++)
     {
         phyPort        = null;
         arrListener[i] = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 构造函数,构造一个Listener对象,并新建线程进行监听
        /// </summary>
        /// <param name="pyhPort"></param>
        public Listener(PhyPort pyhPort)
        {
            this.listenPort     = pyhPort.iRemotePort;
            this.listenerNo     = pyhPort.PhyPortNo;
            this.listenerSocket = pyhPort.socket;
            this.epRemotePoint  = new IPEndPoint(IPAddress.Any, 0);

            this.listenerThread = new Thread(ListenerHandleFunc);
            this.listenerThread.Start();
        }
Beispiel #3
0
        /// <summary>
        /// 新增一个模拟物理端口,并为其绑定一个Listener
        /// </summary>
        /// <param name="iPhyPortNo">物理端口号,大于0小于4</param>
        /// <param name="iRemotePort">监听端口</param>
        /// <param name="iLocalPort">发送端口</param>
        /// <returns></returns>
        public Const.EN_RET_CODE AddPort(int iPhyPortNo, int iRemotePort, int iLocalPort)
        {
            if (iPhyPortNo > Const.MAX_DEVICE_NUM || iPhyPortNo < Const.MIN_DEVICE_NUM)
            {
                return(Const.EN_RET_CODE.EN_RET_PHY_PORT_OVERFLOW);
            }

            PhyPort p = new PhyPort(iPhyPortNo, iRemotePort, iLocalPort);

            phyPort = p;
            Listener listener = new Listener(p);

            arrListener[iPhyPortNo] = listener;

            return(Const.EN_RET_CODE.EN_RET_SUCC);
        }