Beispiel #1
0
        /// <summary>
        /// This constructor is for use with a unicast reflector.  This constructor sends JOIN messages
        /// to the given reflector endpoint.
        ///
        /// </summary>
        /// <param name="reflectorEP"></param>
        /// <param name="multicastEP"></param>
        /// <param name="timeout"></param>
        public UdpListener(IPEndPoint multicastEP, IPEndPoint reflectorEP, int timeout)
        {
            LstSocks.Socket.SockInterfacePair sip = LstSocks.Socket.GetSharedSocket(reflectorEP);
            this.sock = sip.sock;
            this.externalInterface = sip.extInterface;
            this.nextHopEP         = reflectorEP;
            this.multicastEP       = multicastEP;

            // check whether we must "force" the local port to equal the remote port -- this is done
            // for clients behind picky firewalls.  If not, use port number 0 to indicate a "don't care"

            int port = 0;

            try
            {
                string forcePort = ConfigurationManager.AppSettings["MSR.LST.Net.ForceLocalUnicastPorts"];
                bool   force     = Boolean.Parse(forcePort);
                if (force)
                {
                    port = reflectorEP.Port;
                }
            }
            catch (Exception) { }

            lock (sip)
            {
                if (!sip.Initialized)
                {
                    try
                    {
                        InitializeSocket(port, timeout);

                        // notify the reflector of our presence...
                        joiner = new UdpReflectorJoiner(nextHopEP, multicastEP);
                        joiner.Start();

                        sip.Initialized = true;
                    }
                    catch
                    {
                        this.Dispose();
                        throw;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This constructor is for use with a unicast reflector.  This constructor sends JOIN messages
        /// to the given reflector endpoint.
        /// 
        /// </summary>
        /// <param name="reflectorEP"></param>
        /// <param name="multicastEP"></param>
        /// <param name="timeout"></param>
        public UdpListener(IPEndPoint multicastEP, IPEndPoint reflectorEP, int timeout)
        {
                    
            LstSocks.Socket.SockInterfacePair sip = LstSocks.Socket.GetSharedSocket(reflectorEP);
            this.sock = sip.sock;
            this.externalInterface = sip.extInterface;
            this.nextHopEP = reflectorEP;
            this.multicastEP = multicastEP;

            // check whether we must "force" the local port to equal the remote port -- this is done
            // for clients behind picky firewalls.  If not, use port number 0 to indicate a "don't care"

            int port = 0;

            try
            {
                string forcePort = ConfigurationManager.AppSettings["MSR.LST.Net.ForceLocalUnicastPorts"];
                bool force = Boolean.Parse(forcePort);
                if (force)
                    port = reflectorEP.Port;
            }
            catch (Exception) { }

            lock (sip)
            {
                if (!sip.Initialized)
                {
                    try
                    {
                        InitializeSocket(port, timeout);

                        // notify the reflector of our presence...
                        joiner = new UdpReflectorJoiner(nextHopEP, multicastEP);                        
                        joiner.Start();

                        sip.Initialized = true;
                    }
                    catch
                    {
                        this.Dispose();
                        throw;
                    }
                }
            }
        }