Пример #1
0
        //   private IReceiveEvent responseHandler;

        public ListeningServer(bool tranasfer, string function, IPAddress ip, int port)
        {
            isTransfer = tranasfer;
            //this.responseHandler = responseHandler;
            this.function = function;
            this.ip       = ip;
            this.port     = port;
            delegado      = new Connection.ConnectionDroppedDelegate(OneConnectionDroppedEvent);
            (thread = new Thread(new ThreadStart(Listen))).Start();
        }
Пример #2
0
        Connection.ConnectionDroppedDelegate dnsCaeDelegado;//delegado = new Connection.ConnectionDroppedDelegate(OneConnectionDroppedEvent);

        public Program()
        {
            log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));
            log4net.GlobalContext.Properties["serverName"] = Settings.GetInstance().GetProperty("server.name", "rodrigo-nb");
            log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            Console.Title = "Servidor De Contenidos: " + Settings.GetInstance().GetProperty("server.name", "rodrigo-nb").ToUpper();
            Console.WriteLine("----- Servidor De Contenidos -----");
            UsersContactsPersistenceHandler.GetInstance().LoadContacts();
            log.Info("contactos cargados");
            Console.WriteLine("contactos cargados");

            Console.WriteLine("[{0}] Starting server...", DateTime.Now);

            string listenAddressStr = Settings.GetInstance().GetProperty("listen.ip", "ANY");

            IPAddress ip            = "ANY".Equals(listenAddressStr) ? IPAddress.Any : IPAddress.Parse(listenAddressStr);
            int       port          = int.Parse(Settings.GetInstance().GetProperty("server.port", "2001"));
            int       portTransfers = int.Parse(Settings.GetInstance().GetProperty("server.transfers.port", "20001"));


            transferServer = new ListeningServer(true, "Transfers", ip, portTransfers);
            controlServer  = new ListeningServer(false, "Control", ip, port);


            Console.WriteLine("[{0}] Server is running properly!", DateTime.Now);
            log.Info("Server is running properly!");



            if (!DEBUG)
            {
                dnsCaeDelegado = new Connection.ConnectionDroppedDelegate(DisconnectServers);
                Console.WriteLine("[{0}] Connecting Dns...", DateTime.Now);
                dns = new DNSConnection(dnsCaeDelegado);
                try
                {
                    dns.SetupConn();
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    log.ErrorFormat("No se pudo registrar con el DNS, terminando", e);
                    running  = false;
                    dnsError = true;
                    //  throw new Exception("No se pudo registrar con el DNS, terminando", e);
                }
                Console.WriteLine("[{0}] DNS connection ready...", DateTime.Now);
            }
            else
            {
                Console.WriteLine("[{0}] Modo DEBUG Sin conezion al Dns...", DateTime.Now);
            }
        }
Пример #3
0
 public DNSConnection(Connection.ConnectionDroppedDelegate delegado)
 {
     this.delegado = delegado;
 }