2 // System.Net.WebConnectionGroup
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
10 using System.Collections;
11 using System.Net.Sockets;
15 class WebConnectionGroup
20 ArrayList connections;
22 public WebConnectionGroup (ServicePoint sPoint, string name, IPAddress address)
26 this.address = address;
27 connections = new ArrayList (1);
30 public WebConnection GetConnection (string name)
32 WebConnection cnc = null;
34 WeakReference cncRef = null;
36 // Remove disposed connections
37 int end = connections.Count;
38 ArrayList removed = null;
39 for (int i = 0; i < end; i++) {
40 cncRef = (WeakReference) connections [i];
41 cnc = cncRef.Target as WebConnection;
44 removed = new ArrayList (1);
50 if (removed != null) {
51 for (int i = removed.Count - 1; i >= 0; i--)
52 connections.RemoveAt ((int) removed [i]);
55 //TODO: Should use the limits in the config file.
56 if (connections.Count == 0) {
57 cnc = new WebConnection (this, sPoint);
58 connections.Add (new WeakReference (cnc));
60 cncRef = (WeakReference) connections [connections.Count - 1];
61 cnc = cncRef.Target as WebConnection;