using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
-#if NET_4_5
using System.Threading.Tasks;
-#endif
#if !MOBILE
using Mono.Net.Dns;
static Dns ()
{
- System.Net.Sockets.Socket.CheckProtocolSupport();
-
#if !MOBILE
if (Environment.GetEnvironmentVariable ("MONO_DNS") != null) {
resolver = new SimpleResolver ();
[Obsolete ("Use BeginGetHostEntry instead")]
public static IAsyncResult BeginGetHostByName (string hostName, AsyncCallback requestCallback, object stateObject)
{
+#if FEATURE_NO_BSD_SOCKETS
+ throw new PlatformNotSupportedException ("System.Net.Dns:BeginGetHostByName is not supported on this platform.");
+#else
if (hostName == null)
throw new ArgumentNullException ("hostName");
GetHostByNameCallback c = new GetHostByNameCallback (GetHostByName);
return c.BeginInvoke (hostName, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
}
[Obsolete ("Use BeginGetHostEntry instead")]
public static IAsyncResult BeginResolve (string hostName, AsyncCallback requestCallback, object stateObject)
{
+#if FEATURE_NO_BSD_SOCKETS
+ throw new PlatformNotSupportedException ("System.Net.Dns:BeginResolve is not supported on this platform.");
+#else
if (hostName == null)
throw new ArgumentNullException ("hostName");
ResolveCallback c = new ResolveCallback (Resolve);
return c.BeginInvoke (hostName, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
}
public static IAsyncResult BeginGetHostAddresses (string hostNameOrAddress, AsyncCallback requestCallback, object state)
public static IAsyncResult BeginGetHostEntry (string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
{
+#if FEATURE_NO_BSD_SOCKETS
+ throw new PlatformNotSupportedException ("System.Net.Dns:GetHostEntry is not supported on this platform.");
+#else
if (hostNameOrAddress == null)
throw new ArgumentNullException ("hostName");
if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0")
GetHostEntryNameCallback c = new GetHostEntryNameCallback (GetHostEntry);
return c.BeginInvoke (hostNameOrAddress, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
}
public static IAsyncResult BeginGetHostEntry (IPAddress address, AsyncCallback requestCallback, object stateObject)
{
+#if FEATURE_NO_BSD_SOCKETS
+ throw new PlatformNotSupportedException ("System.Net.Dns:BeginGetHostEntry is not supported on this platform.");
+#else
if (address == null)
throw new ArgumentNullException ("address");
GetHostEntryIPCallback c = new GetHostEntryIPCallback (GetHostEntry);
return c.BeginInvoke (address, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
}
[Obsolete ("Use EndGetHostEntry instead")]
[Obsolete ("Use GetHostEntry instead")]
public static IPHostEntry GetHostByName (string hostName)
{
+#if FEATURE_NO_BSD_SOCKETS
+ if (!string.IsNullOrEmpty (hostName))
+ throw new PlatformNotSupportedException ("System.Net.Dns:GetHostByName is not supported on this platform.");
+#endif // FEATURE_NO_BSD_SOCKETS
if (hostName == null)
throw new ArgumentNullException ("hostName");
string h_name;
[Obsolete ("Use GetHostEntry instead")]
public static IPHostEntry Resolve(string hostName)
{
+#if FEATURE_NO_BSD_SOCKETS
+ throw new PlatformNotSupportedException ("System.Net.Dns:Resolve is not supported on this platform.");
+#else
if (hostName == null)
throw new ArgumentNullException ("hostName");
ret = GetHostByName(hostName);
return ret;
+#endif // FEATURE_NO_BSD_SOCKETS
}
-#if NET_4_5
public static Task<IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress)
{
return Task<IPAddress[]>.Factory.FromAsync (BeginGetHostAddresses, EndGetHostAddresses, hostNameOrAddress, null);
{
return Task<IPHostEntry>.Factory.FromAsync (BeginGetHostEntry, EndGetHostEntry, hostNameOrAddress, null);
}
-#endif
}
}