private bool disposedValue = false;             // To detect redundant calls

            // IDisposable
            protected virtual void Dispose(bool disposing)
            {
                if (!this.disposedValue)
                {
                    if (disposing)
                    {
                        // TODO: free other state (managed objects).

                        lock (this._serversTable)
                        {
                            IEnumerator   enumm  = this._serversTable.GetEnumerator();
                            SocketsServer server = null;

                            while (enumm.MoveNext())
                            {
                                server = (SocketsServer)(((DictionaryEntry)enumm.Current).Value);
                                server.Dispose();
                            }
                        }
                    }

                    // TODO: free your own state (unmanaged objects).
                    // TODO: set large fields to null.
                }
                this.disposedValue = true;
            }
            internal void LogClientDisconnectionFromPublication(DPE_DataPublicationsClient stxdssClient, string PublicationName)
            {
                try
                {
                    this.UnLogClientForPublicationDataReception(stxdssClient, PublicationName);
                    int connectedClients = this.GetConnectedClientsToPublicationCount(PublicationName);
                    if (connectedClients <= 0)
                    {
                        //removes all the handles to receive data for this publication because nobody will be use it

                        //removes the multicast clientss if exists
                        MultiCastDataReplicatorClient publicationMultiCastClient = default(MultiCastDataReplicatorClient);
                        publicationMultiCastClient = (MultiCastDataReplicatorClient)this._MultiCastDataReplicatorClientsTable[PublicationName];
                        if (!(publicationMultiCastClient == null))
                        {
                            publicationMultiCastClient.Dispose();
                        }
                        this._MultiCastDataReplicatorKeyStringsTable.Remove(PublicationName);
                        this._MultiCastDataReplicatorClientsTable.Remove(PublicationName);

                        SocketsServer listener = default(SocketsServer);
                        listener = (SocketsServer)this._SocketServersListenersTable[PublicationName];
                        if (!(listener == null))
                        {
                            listener.Dispose();
                        }
                        this._SocketServersListenersTable.Remove(PublicationName);
                    }
                }
                catch (Exception)
                {
                }
            }
            private void DisposeServer(SocketsServer server)
            {
                if (!(server == null))
                {
                    if (this._serversTable.ContainsKey(server.ServerID))
                    {
                        server.ClientDataReceived       -= eventHandling_ClientDataReceived;
                        server.NewClientConnection      -= eventHandling_NewClientConnection;
                        server.ClientConnectionFinished -= eventHandling_ClientConnectionFinished;



                        lock (this._serversTable)
                        {
                            this._serversTable.Remove(server.ServerID);
                            this._serversStack.RemoveServerFromStack(server);
                        }

                        try
                        {
                            if (ServerDisposedEvent != null)
                            {
                                ServerDisposedEvent(server);
                            }
                        }
                        catch (Exception)
                        {
                        }

                        server.Dispose();
                    }
                }
            }