Exemple #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;
                }
            }
        }