Esempio n. 1
0
        /// <summary>
        /// Attempts to advertise the service on the network.
        /// </summary>
        public void Publish()
        {
            Stop();

            registerReplyCb = new mDNSImports.DNSServiceRegisterReply(RegisterReply);

            DNSServiceErrorType err;

            ushort txtRecordLen = (TXTRecordData != null) ? Convert.ToUInt16(TXTRecordData.Length) : (ushort)0;
            ushort port         = (ushort)System.Net.IPAddress.HostToNetworkOrder((short)mPort);

            err = mDNSImports.DNSServiceRegister(out registeredServiceHandle, 0, 0, Name, Type, Domain, null, port, txtRecordLen, TXTRecordData, registerReplyCb, IntPtr.Zero);

            if (err == DNSServiceErrorType.NoError)
            {
                SetupWatchSocket(registeredServiceHandle);
            }
            else
            {
                Stop();
                if (DidNotPublishService != null)
                {
                    DNSServiceException exception = new DNSServiceException("DNSServiceRegister", err);
                    DidNotPublishService(this, exception);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Stops the currently running search or resolution.
        /// </summary>
        public void Stop()
        {
            if (resolveTimer != null)
            {
                resolveTimer.Dispose();
                resolveTimer = null;
            }

            TeardownWatchSocket(registeredServiceHandle);
            if (registeredServiceHandle != IntPtr.Zero)
            {
                mDNSImports.DNSServiceRefDeallocate(registeredServiceHandle);
                registeredServiceHandle = IntPtr.Zero;
            }

            resolveReplyCb  = null;
            registerReplyCb = null;

            TeardownWatchSocket(ipLookupQueryHandle);
            if (ipLookupQueryHandle != IntPtr.Zero)
            {
                mDNSImports.DNSServiceRefDeallocate(ipLookupQueryHandle);
                ipLookupQueryHandle = IntPtr.Zero;
            }

            ipLookupReplyCb = null;
        }
        /// <summary>
        /// Stops the currently running search or resolution.
        /// </summary>
        public void Stop()
        {
            if (resolveTimer != null)
            {
                resolveTimer.Dispose();
                resolveTimer = null;
            }

            TeardownWatchSocket(registeredServiceHandle);
            if (registeredServiceHandle != IntPtr.Zero)
            {
                mDNSImports.DNSServiceRefDeallocate(registeredServiceHandle);
                registeredServiceHandle = IntPtr.Zero;
            }

            resolveReplyCb = null;
            registerReplyCb = null;

            TeardownWatchSocket(ipLookupQueryHandle);
            if (ipLookupQueryHandle != IntPtr.Zero)
            {
                mDNSImports.DNSServiceRefDeallocate(ipLookupQueryHandle);
                ipLookupQueryHandle = IntPtr.Zero;
            }

            ipLookupReplyCb = null;
        }
Esempio n. 4
0
        /// <summary>
        /// Attempts to advertise the service on the network.
        /// </summary>
        public void Publish()
        {
            Stop();

            registerReplyCb = new mDNSImports.DNSServiceRegisterReply(RegisterReply);
            gchSelf = GCHandle.Alloc(this);

            DNSServiceErrorType err;

            UInt16 txtRecordLen = (UInt16)((TXTRecordData != null) ? TXTRecordData.Length : 0);
            UInt16 port = (UInt16)System.Net.IPAddress.HostToNetworkOrder((short)mPort);
            err = mDNSImports.DNSServiceRegister(out sdRef, 0, 0, Name, Type, Domain, null, port,
                txtRecordLen, TXTRecordData, registerReplyCb, (IntPtr)gchSelf);

            if (err != DNSServiceErrorType.kDNSServiceErr_NoError)
            {
                throw new DNSServiceException("DNSServiceRegister", err);
            }

            SetupWatchSocket();
        }
        /// <summary>
        /// Attempts to advertise the service on the network.
        /// </summary>
        public void Publish()
        {
            Stop();

            registerReplyCb = new mDNSImports.DNSServiceRegisterReply(RegisterReply);

            DNSServiceErrorType err;

            ushort txtRecordLen = (TXTRecordData != null) ? Convert.ToUInt16(TXTRecordData.Length) : (ushort)0;
            ushort port = (ushort)System.Net.IPAddress.HostToNetworkOrder((short)mPort);

            err = mDNSImports.DNSServiceRegister(out registeredServiceHandle, 0, 0, Name, Type, Domain, null, port, txtRecordLen, TXTRecordData, registerReplyCb, IntPtr.Zero);

            if (err == DNSServiceErrorType.NoError)
            {
                SetupWatchSocket(registeredServiceHandle);
            }
            else
            {
                Stop();
                if (DidNotPublishService != null)
                {
                    DNSServiceException exception = new DNSServiceException("DNSServiceRegister", err);
                    DidNotPublishService(this, exception);
                }
            }
        }