コード例 #1
0
        /// <summary>
        /// Dispose per the IDisposable pattern
        /// </summary>
        public void Dispose()
        {
            GC.SuppressFinalize(this);

            if (!disposed)
            {
                disposed = true;
                if (sock != null)
                {
                    // if we are using a reflector, send a tear-down message
                    if (!multicastEP.Equals(nextHopEP))
                    {
                        try
                        {
                            if (joiner != null)
                            {
                                joiner.Terminate();
                            }

                            // send a LEAVE message; this might get lost, but that doesn't matter
                            // because the reflector wil time out.
                            UdpSender           sender  = new UdpSender(nextHopEP, 64);
                            UdpReflectorMessage message = new UdpReflectorMessage(UdpReflectorMessageType.LEAVE, multicastEP);

                            sender.Send(message.ToBufferChunk());
                            sender.Dispose();
                        }
                        catch (Exception) { }
                    }

                    LstSocks.Socket.ReleaseSharedSocket(nextHopEP, sock);
                    sock = null;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Send  UDP join messages to the reflector.  There is no acknoweledgement, so we send 
        /// a series of these messages, pausing briefly in between.
        /// 
        /// A bit of ugliness: the joiner works over both C#'s built in socket, as well as CXP's 
        /// UDPSender.  If the class was initialized without a Socket, then we create a locale UdpSender.
        /// This is necessary because the client uses UdpSender, whereas the reflector uses raw sockets.
        /// </summary>
        private void SendJoinMessages()
        {
            Debug.Assert(reflectorEP != null);
            Debug.Assert(multicastEP != null);
            
            UdpSender sender = null;

            try
            {
                sender = new UdpSender(this.reflectorEP, 64);
                sender.DisableLoopback();

                while (alive)
                {
                    UdpReflectorMessage rjm = new UdpReflectorMessage(UdpReflectorMessageType.JOIN, multicastEP);
                    BufferChunk bufferChunk = rjm.ToBufferChunk();
                   
                   
                    // UdpSender, as used by CXPClient
                    sender.Send(bufferChunk);
                    

                    Thread.Sleep(JOIN_MESSAGE_DELAY);
                }
            }
            catch
            {
                
            }
            finally
            {
                if (sender != null)
                    sender.Dispose();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: psyCHOder/conferencexp
        public TestProgram(bool useMulticast)
        {
            IPEndPoint multicastEP = new IPEndPoint(IPAddress.Parse(multicastAddr), multicastPort);
            IPEndPoint reflectorEP = new IPEndPoint(IPAddress.Parse(reflectorAddr), reflectorPort);

            if (useMulticast)
            {
                listener = new UdpListener(multicastEP, 0);
                sender = new UdpSender(multicastEP, 64);
            }
            else
            {
                // reflector
                //listener = new UdpListener(multicastEP, reflectorEP, 0);
                sender = new UdpSender(reflectorEP, 64);
            }

            Thread thread1 = new Thread(SendSomeStuff);
            thread1.Start();

            Thread thread2 = new Thread(ReceiveSomeStuff);
            thread2.Start();
        }
コード例 #4
0
        /// <summary>
        /// Send  UDP join messages to the reflector.  There is no acknoweledgement, so we send
        /// a series of these messages, pausing briefly in between.
        ///
        /// A bit of ugliness: the joiner works over both C#'s built in socket, as well as CXP's
        /// UDPSender.  If the class was initialized without a Socket, then we create a locale UdpSender.
        /// This is necessary because the client uses UdpSender, whereas the reflector uses raw sockets.
        /// </summary>
        private void SendJoinMessages()
        {
            Debug.Assert(reflectorEP != null);
            Debug.Assert(multicastEP != null);

            UdpSender sender = null;

            try
            {
                sender = new UdpSender(this.reflectorEP, 64);
                sender.DisableLoopback();

                while (alive)
                {
                    UdpReflectorMessage rjm         = new UdpReflectorMessage(UdpReflectorMessageType.JOIN, multicastEP);
                    BufferChunk         bufferChunk = rjm.ToBufferChunk();


                    // UdpSender, as used by CXPClient
                    sender.Send(bufferChunk);


                    Thread.Sleep(JOIN_MESSAGE_DELAY);
                }
            }
            catch
            {
            }
            finally
            {
                if (sender != null)
                {
                    sender.Dispose();
                }
            }
        }
コード例 #5
0
ファイル: udplistener.cs プロジェクト: psyCHOder/conferencexp
        /// <summary>
        /// Dispose per the IDisposable pattern
        /// </summary>
        public void Dispose()
        {
            GC.SuppressFinalize(this);
            
            if(!disposed) 
            {
                disposed = true;
                if (sock != null)
                {
                    // if we are using a reflector, send a tear-down message
                    if (!multicastEP.Equals(nextHopEP))
                    {
                        try
                        {
                            if (joiner != null)
                                joiner.Terminate();

                            // send a LEAVE message; this might get lost, but that doesn't matter
                            // because the reflector wil time out.
                            UdpSender sender = new UdpSender(nextHopEP, 64);
                            UdpReflectorMessage message = new UdpReflectorMessage(UdpReflectorMessageType.LEAVE, multicastEP);

                            sender.Send(message.ToBufferChunk());
                            sender.Dispose();
                        }
                        catch (Exception) { }
                    }

                    LstSocks.Socket.ReleaseSharedSocket(nextHopEP, sock);
                    sock = null;
                }
            }
        }