[Mono.Security]: Add 'MonoTlsProvider.SupportsCleanShutdown' and 'MonoTlsSettings...
[mono.git] / mcs / class / System / System.Net / ServicePoint.cs
index 13c06ec493f499c3f5636c35248940ba13b3a6cc..9b6cc5cc5e4d39b218d617e542910fb2fdb1bab6 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Net
 {
        public class ServicePoint
        {
-               Uri uri;
+               readonly Uri uri;
                int connectionLimit;
                int maxIdleTime;
                int currentConnections;
@@ -345,15 +345,31 @@ namespace System.Net
                                lock (hostE) {
                                        string uriHost = uri.Host;
 
-                                       if (host == null || HasTimedOut) {
-                                               lastDnsResolve = DateTime.UtcNow;
+                                       // Cannot do DNS resolution on literal IP addresses
+                                       if (uri.HostNameType == UriHostNameType.IPv6 || uri.HostNameType == UriHostNameType.IPv4) {
+                                               if (host != null)
+                                                       return host;
 
-                                               try {
-                                                       host = Dns.GetHostEntry (uriHost);
-                                               }
-                                               catch (Exception) {
-                                                       return null;
+                                               if (uri.HostNameType == UriHostNameType.IPv6) {
+                                                       // Remove square brackets
+                                                       uriHost = uriHost.Substring (1, uriHost.Length - 2);
                                                }
+
+                                               // Creates IPHostEntry
+                                               host = new IPHostEntry();
+                                               host.AddressList = new IPAddress[] { IPAddress.Parse (uriHost) };
+                                               return host;
+                                       }
+
+                                       if (!HasTimedOut && host != null)
+                                               return host;
+
+                                       lastDnsResolve = DateTime.UtcNow;
+
+                                       try {
+                                               host = Dns.GetHostEntry (uriHost);
+                                       } catch {
+                                               return null;
                                        }
                                }
 
@@ -489,6 +505,11 @@ namespace System.Net
                                return true;
                        }
                }
+
+               internal Socket GetConnection(PooledStream PooledStream, object owner, bool async, out IPAddress address, ref Socket abortSocket, ref Socket abortSocket6)
+               {
+                       throw new NotImplementedException ();
+               }
        }
 }