aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/SocketRegistry.cs
blob: 2ebf80cdcacada0ae0d55c0f4a491c8de7b26528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Created by SharpDevelop.
 * User: Adam Stevenson
 * Date: 6/13/2007
 * Time: 12:55 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;

namespace OpenSim.Servers
{
	/// <summary>
	/// 
	/// </summary>
	public class SocketRegistry
	{
		static List<Socket> _Sockets;

        static SocketRegistry()
        {
            _Sockets = new List<Socket>();
        }

		private SocketRegistry()
		{
			
		}
		
		public static void Register(Socket pSocket)
		{
            _Sockets.Add(pSocket);
		}

        public static void Unregister(Socket pSocket)
        {
            _Sockets.Remove(pSocket);
        }

        public static void UnregisterAllAndClose()
        {
            int iSockets = _Sockets.Count;

            for (int i = 0; i < iSockets; i++)
            {
                try
                {
                    _Sockets[i].Close();
                }
                catch
                {

                }
            }

            _Sockets.Clear();
        }
    }
}