Exemplo n.º 1
0
        /// <summary> Initialize everything.
        ///
        /// </summary>
        public async Task Init()
        {
            IPAddress address = _cachedAddress;
            string    name    = _cachedName;
            // A host name with "." is illegal. so strip off everything and append .local.
            int idx = name.IndexOf(".");

            if (idx > 0)
            {
                name = name.Substring(0, (idx) - (0));
            }
            name += ".local.";
            // localHost to IP address binding
            localHost = new HostInfo(address, name);

            cache = new DNSCache(100);

            listeners        = ArrayList.Synchronized(new ArrayList());
            serviceListeners = new Hashtable();
            typeListeners    = new ArrayList();

            services     = Hashtable.Synchronized(new Hashtable(20));
            serviceTypes = Hashtable.Synchronized(new Hashtable(20));

            // REMIND: If I could pass in a name for the Timer thread,
            //         I would pass 'JmDNS.Timer'.
            //timer = new Timer();
            new RecordReaper(this).start();
            shutdown = new SupportClass.ThreadClass(new WorkItemHandler(new Shutdown(this).Run));

            // TODO: make this run at shutdown
            //Process.GetCurrentProcess().addShutdownHook(shutdown.Instance);

            incomingListener = new SupportClass.ThreadClass(new WorkItemHandler(new SocketListener(this).Run));

            // Bind to multicast socket
            await OpenMulticastSocket(localHost, ipv6);

            Start(services.Values);
        }
Exemplo n.º 2
0
Arquivo: mDNS.cs Projeto: pisker/mDNS
		/// <summary> Initialize everything.
		/// 
		/// </summary>
		public async Task Init()
		{

            IPAddress address = _cachedAddress;
            string name = _cachedName;
            // A host name with "." is illegal. so strip off everything and append .local.
            int idx = name.IndexOf(".");
			if (idx > 0)
				name = name.Substring(0, (idx) - (0));
			name += ".local.";
			// localHost to IP address binding
			localHost = new HostInfo(address, name);
			
			cache = new DNSCache(100);
			
			listeners = ArrayList.Synchronized(new ArrayList());
			serviceListeners = new Hashtable();
			typeListeners = new ArrayList();
			
			services = Hashtable.Synchronized(new Hashtable(20));
			serviceTypes = Hashtable.Synchronized(new Hashtable(20));
			
			// REMIND: If I could pass in a name for the Timer thread,
			//         I would pass 'JmDNS.Timer'.
			//timer = new Timer();
			new RecordReaper(this).start();
			shutdown = new SupportClass.ThreadClass(new WorkItemHandler(new Shutdown(this).Run));
			
			// TODO: make this run at shutdown
			//Process.GetCurrentProcess().addShutdownHook(shutdown.Instance);
			
			incomingListener = new SupportClass.ThreadClass(new WorkItemHandler(new SocketListener(this).Run));
			
			// Bind to multicast socket
			await OpenMulticastSocket(localHost, ipv6);
			Start(services.Values);
		}