Exemple #1
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Init()
        {
            if (isInit)
            {
                return;
            }
            lock (lock_obj)
            {
                if (isInit)
                {
                    return;
                }
                isInit = true;
                uDP.Bind();
                // uDP.UDPCall += UDP_UDPCall;
                uDP.UDPCall += UDP_UDPCall1;
                Thread udprec = new Thread(() =>
                {
                    uDP.StartRecvice();
                });
                udprec.IsBackground = true;
                udprec.Name         = "udpRec";

                if (!udprec.IsAlive)
                {
                    udprec.Start();
                }
                tcp.Bind();
                tcp.CallSrv += Tcp_CallSrv;

                TcpAddress = tcp.LocalPoint.Address + "_" + tcp.LocalPoint.Port;
                UdpAddress = uDP.LocalPoint.Address + "_" + uDP.LocalPoint.Port;
            }
        }
Exemple #2
0
 public void Start()
 {
     if (IsPtP && LocalAddress != null)
     {
         if (LocalAddress.Protol == 0)
         {
             TcpServerSocket tcpServer = new TcpServerSocket();
             tcpServer.Bind(LocalAddress.Port);
             tcpServer.CallSrv += TcpServer_CallSrv;
         }
         else
         {
             UDPSocketPack uDP = new UDPSocketPack();
             uDP.Bind(LocalAddress.Port, LocalAddress.Address);
             uDP.UDPCall += UDP_UDPCall;
         }
     }
 }