예제 #1
0
        public void Release()
        {
            _listeningSocket.Shutdown(SocketShutdown.Both);
            _listeningSocket.Close();

            var listeningThreads = _listeningThreads.ToList();

            foreach (var lt in listeningThreads)
            {
                if (lt.IsAlive)
                {
                    lt.Abort();
                }
            }

            _listeningThreads.Clear();

            var connections = _connectionsPool?.GetUsedObjects();

            if (connections != null && connections.Any())
            {
                foreach (var connection in connections)
                {
                    connection.Dispose();

                    _connectionsPool.Release(connection);
                }
            }
        }