Exemplo n.º 1
0
        public Status()
        {
            // Check if there is no more than 1 instance
            if (Instance)
            {
                // If there is, then, send error
                throw new InvalidOperationException("There cannot be more than one status instance");
            }
            else
            {
                Instance = true;
            }

            // Prepare connection
            IPHostEntry ipHostInfo    = Dns.GetHostEntry("192.168.1.65");
            IPAddress   ipAddress     = ipHostInfo.AddressList[0];
            IPEndPoint  localEndPoint = new IPEndPoint(ipAddress, 11000);

            // Tcp Socket
            listener = new TcpListener(localEndPoint.Address, localEndPoint.Port);
            //! Try for check only one instance of the console
            try
            {
                // Start listen
                listener.Start();
            }
            catch (SocketException sE)
            {
                if (sE.ErrorCode == sE.ErrorCode)
                {
                    MasterConsole.FoccusOneConsole();
                }
            }
        }