Example #1
0
 /// <summary>
 /// Запускает прослушку заданного порта.
 /// </summary>
 /// <param name="inPort"></param>
 /// <param name="udpSocketListener"></param>
 public UDPSocket(int outPort, int inPort, UDPSocketListener udpSocketListener)
 {
     this.udpSocketListener = udpSocketListener;
     try
     {
         localOutSocket = new UdpClient(outPort); //SocketExc
         localInSocket  = new UdpClient(inPort);  //SocketExc
         startNode();
     }
     catch (ArgumentOutOfRangeException e)
     { //localSocket == null; listeningThread == null
         udpSocketListener.onSocketCreationException(this, "The port parameter is greater than MaxPort or less than MinPort.");
         setAlive(false);
     }
     catch (SocketException e)
     { //localSocket == null; listeningThread == null
         udpSocketListener.onSocketCreationException(this, e.Message);
         setAlive(false);
     }
 }
        private void MMSService()
        {
            try
            {
                //1.Post information to PS
                CommonVariables.LogTool.Log("Begin post server information to portal server " + CommonVariables.PSIP);
                string PSMsg = PostServerInfo();
                if (!string.IsNullOrEmpty(PSMsg))
                {
                    CommonVariables.LogTool.Log("Wait Start Command");
                    CommonVariables.LogTool.Log("IP:" + CommonVariables.MMSIP + "    Port:" + CommonVariables.MMSPort.ToString());

                    socketListener = new UDPSocketListener();
                    socketListener.BeginService();
                    return;
                }
                CommonVariables.LogTool.Log("Post PS Failed");
            }
            catch (Exception ex)
            {
                CommonVariables.LogTool.Log(ex.Message + ex.StackTrace);
            }
        }
 public void StopMMSService()
 {
     //CommonVariables.UAInfoContorl.StopMainThread();
     socketListener.CloseListener();
     socketListener = null;
 }