[System] Suppress a few instances of CS0618 obsolete warnings
[mono.git] / mcs / class / System / System.Net / EndPointManager.cs
index eb4c79852c7269eba8ba196f6ba32c3eed43acb1..9a103f45cd72898eaec07552c2b693cde4f9816f 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if SECURITY_DEP
-
 using System.Collections;
 using System.Collections.Generic;
 namespace System.Net {
@@ -82,9 +80,21 @@ namespace System.Net {
                static EndPointListener GetEPListener (string host, int port, HttpListener listener, bool secure)
                {
                        IPAddress addr;
-                       if (IPAddress.TryParse(host, out addr) == false)
+                       if (host == "*")
                                addr = IPAddress.Any;
-
+                       else if (IPAddress.TryParse(host, out addr) == false){
+                               try {
+#pragma warning disable 618
+                                       IPHostEntry iphost = Dns.GetHostByName(host);
+#pragma warning restore 618
+                                       if (iphost != null)
+                                               addr = iphost.AddressList[0];
+                                       else
+                                               addr = IPAddress.Any;
+                               } catch {
+                                       addr = IPAddress.Any;
+                               } 
+                       }
                        Hashtable p = null;  // Dictionary<int, EndPointListener>
                        if (ip_to_endpoints.ContainsKey (addr)) {
                                p = (Hashtable) ip_to_endpoints [addr];
@@ -97,7 +107,7 @@ namespace System.Net {
                        if (p.ContainsKey (port)) {
                                epl = (EndPointListener) p [port];
                        } else {
-                               epl = new EndPointListener (addr, port, secure);
+                               epl = new EndPointListener (listener, addr, port, secure);
                                p [port] = epl;
                        }
 
@@ -148,5 +158,4 @@ namespace System.Net {
                }
        }
 }
-#endif