/// <summary>
        /// Gets the socket from pool.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <returns>A <see cref="SharedCacheTcpClient"/> object.</returns>
        public SharedCacheTcpClient GetSocketFromPool(string host)
        {
            #region Access Log
#if TRACE
            {
                Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
            }
#endif
            #endregion Access Log
#if DEBUG
            Debug.WriteLine(string.Format("retrieve socket from host: {0}", host));
#endif
            TcpSocketConnectionPool pool = pools[host];
            return(pool.GetSocket());
        }
        /// <summary>
        /// Puts the socket to pool.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="socket">The socket.</param>
        public void PutSocketToPool(string host, SharedCacheTcpClient socket)
        {
            #region Access Log
#if TRACE
            {
                Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
            }
#endif
#if DEBUG
            Debug.WriteLine(string.Format("put socket to pool: {0}", host));
#endif
            #endregion Access Log

            TcpSocketConnectionPool pool = pools[host];
            pool.PutSocket(socket);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ManageTcpSocketConnectionPool"/> class.
        /// </summary>
        public ManageTcpSocketConnectionPool(bool instanceClientPools)
        {
            #region Access Log
#if TRACE
            {
                Handler.LogHandler.Tracking("Access Method: " + this.GetType().ToString() + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
            }
#endif
#if DEBUG
            Debug.WriteLine(string.Format("socket connection pool created for {0}", instanceClientPools ? "client" : "server"));
#endif
            #endregion Access Log

            lock (bulkObject)
            {
                if (this.configuredHosts.Count == 0)
                {
                    if (instanceClientPools)
                    {
                        #region reading provider data from the config file
                        foreach (Configuration.Client.IndexusServerSetting configEntry in Provider.Cache.IndexusDistributionCache.SharedCache.ServersList)
                        {
                            // default port!
                            int port = 48888;
                            int.TryParse(configEntry.Port, out port);
                            this.configuredHosts.Add(configEntry.IpAddress, port);
                        }
                        #endregion

                        #region upon replication the system creates also a pool for backup replication server nodes
                        foreach (Configuration.Client.IndexusServerSetting configEntry in Provider.Cache.IndexusDistributionCache.SharedCache.ReplicatedServersList)
                        {
                            int port = 48888;
                            int.TryParse(configEntry.Port, out port);
                            this.configuredHosts.Add(configEntry.IpAddress, port);
                        }
                        #endregion
                    }
                    else
                    {
                        #region ensure client does not configure the instance itself!!!
                        IPAddress ip = Handler.Network.GetFirstIPAddress();

                        foreach (Configuration.Server.IndexusServerSetting configEntry in Provider.Server.IndexusServerReplicationCache.CurrentProvider.ServersList)
                        {
                            // validate server does not add itself.
                            if (!ip.ToString().Equals(configEntry.IpAddress))
                            {
                                this.configuredHosts.Add(configEntry.IpAddress, configEntry.Port);
                            }
                        }
                        #endregion
                    }
                    double doubleMs = 180000;
                    if (instanceClientPools)
                    {
                        doubleMs = Provider.Cache.IndexusDistributionCache.ProviderSection.ClientSetting.SocketPoolValidationInterval.TotalMilliseconds;
                    }
                    else
                    {
                        doubleMs = Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.SocketPoolValidationInterval.TotalMilliseconds;
                    }

#if DEBUG
                    Debug.WriteLine("SocketPoolValidationInterval amount:" + doubleMs.ToString());
#endif

                    this.validatePoolTimer          = new System.Timers.Timer();
                    this.validatePoolTimer.Elapsed += new ElapsedEventHandler(ValidateConnectionPools);
                    this.validatePoolTimer.Interval = doubleMs;
                    this.validatePoolTimer.Start();
                }
                // init each for each entry a pool
                foreach (KeyValuePair <string, int> host in this.configuredHosts)
                {
                    TcpSocketConnectionPool newPool = new TcpSocketConnectionPool();
                    newPool.Host = host.Key;
                    newPool.Port = host.Value;
                    pools.Add(host.Key, newPool);

                    int defaultPoolSize = 5;
                    if (instanceClientPools)
                    {
                        defaultPoolSize = Provider.Cache.IndexusDistributionCache.ProviderSection.ClientSetting.SocketPoolMinAvailableSize;
                    }
                    else
                    {
                        defaultPoolSize = Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.SocketPoolMinAvailableSize;
                    }
#if DEBUG
                    Debug.WriteLine(string.Format("Pool size is {0} for host {1}", defaultPoolSize, host.Key));
#endif
                    // set tcp pool size
                    pools[host.Key].PoolSize = defaultPoolSize;
                    // enable pool
                    pools[host.Key].Enable();
                }
            }
        }