diff options
Diffstat (limited to 'Common/OpenSim.Servers/SocketRegistry.cs')
-rw-r--r-- | Common/OpenSim.Servers/SocketRegistry.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Common/OpenSim.Servers/SocketRegistry.cs b/Common/OpenSim.Servers/SocketRegistry.cs new file mode 100644 index 0000000..2ebf80c --- /dev/null +++ b/Common/OpenSim.Servers/SocketRegistry.cs | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Created by SharpDevelop. | ||
3 | * User: Adam Stevenson | ||
4 | * Date: 6/13/2007 | ||
5 | * Time: 12:55 AM | ||
6 | * | ||
7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. | ||
8 | */ | ||
9 | |||
10 | using System; | ||
11 | using System.Collections.Generic; | ||
12 | using System.Net; | ||
13 | using System.Net.Sockets; | ||
14 | |||
15 | namespace OpenSim.Servers | ||
16 | { | ||
17 | /// <summary> | ||
18 | /// | ||
19 | /// </summary> | ||
20 | public class SocketRegistry | ||
21 | { | ||
22 | static List<Socket> _Sockets; | ||
23 | |||
24 | static SocketRegistry() | ||
25 | { | ||
26 | _Sockets = new List<Socket>(); | ||
27 | } | ||
28 | |||
29 | private SocketRegistry() | ||
30 | { | ||
31 | |||
32 | } | ||
33 | |||
34 | public static void Register(Socket pSocket) | ||
35 | { | ||
36 | _Sockets.Add(pSocket); | ||
37 | } | ||
38 | |||
39 | public static void Unregister(Socket pSocket) | ||
40 | { | ||
41 | _Sockets.Remove(pSocket); | ||
42 | } | ||
43 | |||
44 | public static void UnregisterAllAndClose() | ||
45 | { | ||
46 | int iSockets = _Sockets.Count; | ||
47 | |||
48 | for (int i = 0; i < iSockets; i++) | ||
49 | { | ||
50 | try | ||
51 | { | ||
52 | _Sockets[i].Close(); | ||
53 | } | ||
54 | catch | ||
55 | { | ||
56 | |||
57 | } | ||
58 | } | ||
59 | |||
60 | _Sockets.Clear(); | ||
61 | } | ||
62 | } | ||
63 | } | ||