Просмотр исходного кода

[System*] Throw a PlatformNotSupported exception when using the networking stack on watchOS. (#3606)

* [System] Fix line endings for a few files.

Best reviewed by not showing whitespace changes (should be empty diff in that case).

* [System] Fix potential crash in CookieParserTests.

Socket.EndAccept can throw an exception, which will crash the process if it
happens on a threadpool. So handle any exceptions when calling
Socket.EndAccept, and propagate those exceptions out of any threadpool code.

* [System.Net.Http] Throw a PlatformNotSupported exception when using HttpClientHandler on watchOS.

* [System.Net.Http] Tweak tests after watchOS API change.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Extract the HttpListenerResponseHelper class to a separate file.

Extract the HttpListenerResponseHelper class to a separate file so that it's
easier to replace the HttpListenerResponse implementation by using a different
file.

* [System] Throw a PlatformNotSupported exception when using the networking stack on watchOS.

* [System] Tweak tests after watchOS API changes.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Fix potential crash in SocketAcceptAsyncTest.

Fix potential crash in SocketAcceptAsyncTest by catching any exceptions in
code executed on the threadpool so that we never end up with unhandled
exceptions (which may terminate the process).

* [System] Avoid logic in SetUp attributes in tests.

Any type of exception in [SetUp] attributes causes all tests to fail with that
exception.

This even happens for tests that do not need the logic in the [SetUp]
attribute.

So rewrite tests a bit to not use [SetUp] when we can reasonably avoid it, and
instead instantiate class-level variables on first use. This ensures that any
exceptions that occur when initializing those variables are attributed to the
corresponding test, and not all of them.

* [System] Make exception handler (for test) catch more exceptions to avoid unhandled exceptions causing process termination.

* [System] Remove Obsolete attribute on API that throws PNSE.
Rolf Bjarne Kvinge 9 лет назад
Родитель
Сommit
e6536dd5e1
54 измененных файлов с 4193 добавлено и 265 удалено
  1. 1 0
      mcs/build/profiles/monotouch_watch.make
  2. 1 0
      mcs/build/profiles/monotouch_watch_runtime.make
  3. 175 0
      mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.platformnotsupported.cs
  4. 12 0
      mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientHandlerTest.cs
  5. 77 23
      mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs
  6. 1 0
      mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.exclude.sources
  7. 2 0
      mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.sources
  8. 167 0
      mcs/class/System/System.Net.Mail/SmtpClient.platformnotsupported.cs
  9. 4 0
      mcs/class/System/System.Net.Sockets/Socket.cs
  10. 191 0
      mcs/class/System/System.Net.Sockets/TcpClient.platformnotsupported.cs
  11. 135 0
      mcs/class/System/System.Net.Sockets/TcpListener.platformnotsupported.cs
  12. 241 0
      mcs/class/System/System.Net.Sockets/UdpClient.platformnotsupported.cs
  13. 98 0
      mcs/class/System/System.Net.WebSockets/ClientWebSocket.platformnotsupported.cs
  14. 24 0
      mcs/class/System/System.Net/Dns.cs
  15. 39 0
      mcs/class/System/System.Net/FtpRequestCreator.platformnotsupported.cs
  16. 182 0
      mcs/class/System/System.Net/FtpWebRequest.platformnotsupported.cs
  17. 91 0
      mcs/class/System/System.Net/FtpWebResponse.platformnotsupported.cs
  18. 128 0
      mcs/class/System/System.Net/HttpListener.platformnotsupported.cs
  19. 68 0
      mcs/class/System/System.Net/HttpListenerContext.platformnotsupported.cs
  20. 93 0
      mcs/class/System/System.Net/HttpListenerPrefixCollection.platformnotsupported.cs
  21. 180 0
      mcs/class/System/System.Net/HttpListenerRequest.platformnotsupported.cs
  22. 0 58
      mcs/class/System/System.Net/HttpListenerResponse.cs
  23. 150 0
      mcs/class/System/System.Net/HttpListenerResponse.platformnotsupported.cs
  24. 88 0
      mcs/class/System/System.Net/HttpListenerResponseHelper.cs
  25. 460 0
      mcs/class/System/System.Net/HttpWebRequest.platformnotsupported.cs
  26. 147 0
      mcs/class/System/System.Net/HttpWebResponse.platformnotsupported.cs
  27. 1 0
      mcs/class/System/System.dll.sources
  28. 75 3
      mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs
  29. 0 1
      mcs/class/System/Test/System.Net.Security/SslStreamTest.cs
  30. 8 1
      mcs/class/System/Test/System.Net.Sockets/NetworkStreamTest.cs
  31. 31 15
      mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs
  32. 24 15
      mcs/class/System/Test/System.Net.Sockets/SocketAsyncTest.cs
  33. 204 1
      mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
  34. 16 1
      mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs
  35. 27 1
      mcs/class/System/Test/System.Net.Sockets/TcpListenerTest.cs
  36. 121 1
      mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs
  37. 21 19
      mcs/class/System/Test/System.Net.WebSockets/ClientWebSocketTest.cs
  38. 40 5
      mcs/class/System/Test/System.Net/CookieParserTest.cs
  39. 36 1
      mcs/class/System/Test/System.Net/DnsTest.cs
  40. 0 1
      mcs/class/System/Test/System.Net/FileWebRequestTest.cs
  41. 55 8
      mcs/class/System/Test/System.Net/FtpWebRequestTest.cs
  42. 84 2
      mcs/class/System/Test/System.Net/HttpListener2Test.cs
  43. 66 2
      mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs
  44. 15 1
      mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
  45. 119 6
      mcs/class/System/Test/System.Net/HttpListenerTest.cs
  46. 222 6
      mcs/class/System/Test/System.Net/HttpWebRequestTest.cs
  47. 90 2
      mcs/class/System/Test/System.Net/HttpWebResponseTest.cs
  48. 43 38
      mcs/class/System/Test/System.Net/ServicePointTest.cs
  49. 22 1
      mcs/class/System/Test/System.Net/WebClientTest.cs
  50. 6 0
      mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs
  51. 69 53
      mcs/class/System/Test/System.Net/WebRequestTest.cs
  52. 1 0
      mcs/class/System/mobile_System.dll.sources
  53. 27 0
      mcs/class/System/monotouch_watch_System.dll.exclude.sources
  54. 15 0
      mcs/class/System/monotouch_watch_System.dll.sources

+ 1 - 0
mcs/build/profiles/monotouch_watch.make

@@ -1,6 +1,7 @@
 include $(topdir)/build/profiles/monotouch.make
 include $(topdir)/build/profiles/monotouch.make
 
 
 PROFILE_MCS_FLAGS += \
 PROFILE_MCS_FLAGS += \
+	-d:FEATURE_NO_BSD_SOCKETS \
 	-d:MONOTOUCH_WATCH
 	-d:MONOTOUCH_WATCH
 
 
 NO_THREAD_ABORT=1
 NO_THREAD_ABORT=1

+ 1 - 0
mcs/build/profiles/monotouch_watch_runtime.make

@@ -1,6 +1,7 @@
 include $(topdir)/build/profiles/monotouch_runtime.make
 include $(topdir)/build/profiles/monotouch_runtime.make
 
 
 PROFILE_MCS_FLAGS += \
 PROFILE_MCS_FLAGS += \
+	-d:FEATURE_NO_BSD_SOCKETS \
 	-d:MONOTOUCH_WATCH
 	-d:MONOTOUCH_WATCH
 
 
 NO_THREAD_ABORT=1
 NO_THREAD_ABORT=1

+ 175 - 0
mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.platformnotsupported.cs

@@ -0,0 +1,175 @@
+//
+// System.Net.Http/HttpClientHandler.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace System.Net.Http
+{
+	public class HttpClientHandler : HttpMessageHandler
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.Http.HttpClientHandler is not supported on the current platform.";
+
+		public HttpClientHandler ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public bool AllowAutoRedirect {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DecompressionMethods AutomaticDecompression {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public ClientCertificateOption ClientCertificateOptions {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public CookieContainer CookieContainer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public ICredentials Credentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int MaxAutomaticRedirections {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public long MaxRequestContentBufferSize {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool PreAuthenticate {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IWebProxy Proxy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool SupportsAutomaticDecompression {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool SupportsProxy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool SupportsRedirectConfiguration {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UseCookies {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UseDefaultCredentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UseProxy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		protected override void Dispose (bool disposing)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		HttpResponseMessage CreateResponseMessage (HttpWebResponse wr, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected internal async override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+#if NETSTANDARD
+		public bool CheckCertificateRevocationList {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public X509CertificateCollection ClientCertificates {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public ICredentials DefaultProxyCredentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int MaxConnectionsPerServer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int MaxResponseHeadersLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IDictionary<string,object> Properties {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Func<HttpRequestMessage,X509Certificate2,X509Chain,SslPolicyErrors,bool> ServerCertificateCustomValidationCallback {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public SslProtocols SslProtocols {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+#endif
+	}
+}

+ 12 - 0
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientHandlerTest.cs

@@ -61,6 +61,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Properties_Defaults ()
 		public void Properties_Defaults ()
 		{
 		{
 			var h = new HttpClientHandler ();
 			var h = new HttpClientHandler ();
@@ -83,6 +86,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Properties_Invalid ()
 		public void Properties_Invalid ()
 		{
 		{
 			var h = new HttpClientHandler ();
 			var h = new HttpClientHandler ();
@@ -107,6 +113,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Properties_AfterClientCreation ()
 		public void Properties_AfterClientCreation ()
 		{
 		{
 			var h = new HttpClientHandler ();
 			var h = new HttpClientHandler ();
@@ -119,6 +128,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Disposed ()
 		public void Disposed ()
 		{
 		{
 			var h = new HttpClientHandler ();
 			var h = new HttpClientHandler ();

+ 77 - 23
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs

@@ -263,6 +263,10 @@ namespace MonoTests.System.Net.Http
 
 
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		// Using HttpClientHandler, which indirectly requires BSD sockets.
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CancelRequestViaProxy ()
 		public void CancelRequestViaProxy ()
 		{
 		{
 			var handler = new HttpClientHandler {
 			var handler = new HttpClientHandler {
@@ -321,7 +325,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Proxy_Disabled ()
 		public void Proxy_Disabled ()
 		{
 		{
 			var pp = WebRequest.DefaultWebProxy;
 			var pp = WebRequest.DefaultWebProxy;
@@ -398,7 +404,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Default ()
 		public void Send_Complete_Default ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -443,7 +451,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Version_1_0 ()
 		public void Send_Complete_Version_1_0 ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -491,7 +501,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_ClientHandlerSettings ()
 		public void Send_Complete_ClientHandlerSettings ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -556,7 +568,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_CustomHeaders ()
 		public void Send_Complete_CustomHeaders ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -621,7 +635,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_CustomHeaders_SpecialSeparators ()
 		public void Send_Complete_CustomHeaders_SpecialSeparators ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -656,7 +672,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_CustomHeaders_Host ()
 		public void Send_Complete_CustomHeaders_Host ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -690,7 +708,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Transfer_Encoding_Chunked ()
 		public void Send_Transfer_Encoding_Chunked ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -720,7 +740,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Transfer_Encoding_Custom ()
 		public void Send_Transfer_Encoding_Custom ()
 		{
 		{
 			bool? failed = null;
 			bool? failed = null;
@@ -749,7 +771,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Content ()
 		public void Send_Complete_Content ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -777,7 +801,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Content_MaxResponseContentBufferSize ()
 		public void Send_Complete_Content_MaxResponseContentBufferSize ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -800,7 +826,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
 		public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -827,7 +855,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_NoContent ()
 		public void Send_Complete_NoContent ()
 		{
 		{
 			foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
 			foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
@@ -860,7 +890,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Complete_Error ()
 		public void Send_Complete_Error ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -881,7 +913,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Content_Get ()
 		public void Send_Content_Get ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -901,7 +935,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Content_BomEncoding ()
 		public void Send_Content_BomEncoding ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -926,7 +962,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Content_Put ()
 		public void Send_Content_Put ()
 		{
 		{
 			bool passed = false;
 			bool passed = false;
@@ -952,7 +990,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Content_Put_CustomStream ()
 		public void Send_Content_Put_CustomStream ()
 		{
 		{
 			bool passed = false;
 			bool passed = false;
@@ -1055,7 +1095,9 @@ namespace MonoTests.System.Net.Http
 
 
 		[Test]
 		[Test]
 		[Category ("MobileNotWorking")] // Missing encoding
 		[Category ("MobileNotWorking")] // Missing encoding
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetString_Many ()
 		public void GetString_Many ()
 		{
 		{
 			Action<HttpListenerContext> context = (HttpListenerContext l) => {
 			Action<HttpListenerContext> context = (HttpListenerContext l) => {
@@ -1085,7 +1127,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetByteArray_ServerError ()
 		public void GetByteArray_ServerError ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -1108,7 +1152,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DisallowAutoRedirect ()
 		public void DisallowAutoRedirect ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -1137,7 +1183,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void RequestUriAfterRedirect ()
 		public void RequestUriAfterRedirect ()
 		{
 		{
 			var listener = CreateListener (l => {
 			var listener = CreateListener (l => {
@@ -1178,7 +1226,9 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		/*
 		/*
 		 * Properties may only be modified before sending the first request.
 		 * Properties may only be modified before sending the first request.
 		 */
 		 */
@@ -1209,6 +1259,10 @@ namespace MonoTests.System.Net.Http
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		// Using HttpClientHandler, which indirectly requires BSD sockets.
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		/*
 		/*
 		 * However, this policy is not enforced for custom handlers and there
 		 * However, this policy is not enforced for custom handlers and there
 		 * is also no way a derived class could tell its HttpClientHandler parent
 		 * is also no way a derived class could tell its HttpClientHandler parent

+ 1 - 0
mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.exclude.sources

@@ -0,0 +1 @@
+System.Net.Http/HttpClientHandler.cs

+ 2 - 0
mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.sources

@@ -0,0 +1,2 @@
+#include System.Net.Http.dll.sources
+System.Net.Http/HttpClientHandler.platformnotsupported.cs

+ 167 - 0
mcs/class/System/System.Net.Mail/SmtpClient.platformnotsupported.cs

@@ -0,0 +1,167 @@
+//
+// System.Net.Mail.SmtpClient.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.ComponentModel;
+using System.Security.Cryptography.X509Certificates;
+using System.Threading.Tasks;
+
+namespace System.Net.Mail {
+	public class SmtpClient
+		: IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.Mail.SmtpClient is not supported on the current platform.";
+
+		public SmtpClient ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public SmtpClient (string host)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public SmtpClient (string host, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+#if SECURITY_DEP
+		[MonoTODO("Client certificates not used")]
+		public X509CertificateCollection ClientCertificates {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+#endif
+
+		public string TargetName { get; set; }
+
+		public ICredentialsByHost Credentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public SmtpDeliveryMethod DeliveryMethod {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool EnableSsl {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Host {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string PickupDirectoryLocation {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int Port {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+		
+		public SmtpDeliveryFormat DeliveryFormat {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+		
+		public ServicePoint ServicePoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int Timeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UseDefaultCredentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+#pragma warning disable 0067 // The event `System.Net.Mail.SmtpClient.SendCompleted' is never used
+		public event SendCompletedEventHandler SendCompleted;
+#pragma warning restore 0067
+
+		public void Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected virtual void Dispose (bool disposing)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected void OnSendCompleted (AsyncCompletedEventArgs e)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Send (MailMessage message)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Send (string from, string to, string subject, string body)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task SendMailAsync (MailMessage message)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task SendMailAsync (string from, string recipients, string subject, string body)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void SendAsync (MailMessage message, object userToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void SendAsync (string from, string to, string subject, string body, object userToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void SendAsyncCancel ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}
+

+ 4 - 0
mcs/class/System/System.Net.Sockets/Socket.cs

@@ -877,6 +877,9 @@ namespace System.Net.Sockets
 
 
 		public void Bind (EndPoint localEP)
 		public void Bind (EndPoint localEP)
 		{
 		{
+#if FEATURE_NO_BSD_SOCKETS
+			throw new PlatformNotSupportedException ("System.Net.Sockets.Socket:Bind is not supported on this platform.");
+#else
 			ThrowIfDisposedAndClosed ();
 			ThrowIfDisposedAndClosed ();
 
 
 			if (localEP == null)
 			if (localEP == null)
@@ -896,6 +899,7 @@ namespace System.Net.Sockets
 				is_bound = true;
 				is_bound = true;
 
 
 			seed_endpoint = localEP;
 			seed_endpoint = localEP;
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		private static void Bind_internal (SafeSocketHandle safeHandle, SocketAddress sa, out int error)
 		private static void Bind_internal (SafeSocketHandle safeHandle, SocketAddress sa, out int error)

+ 191 - 0
mcs/class/System/System.Net.Sockets/TcpClient.platformnotsupported.cs

@@ -0,0 +1,191 @@
+//
+// System.Net.Sockets.TcpClient.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace System.Net.Sockets
+{
+	public class TcpClient : IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.Sockets.TcpClient is not supported on the current platform.";
+
+		public TcpClient ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpClient (AddressFamily family)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpClient (IPEndPoint localEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpClient (string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected bool Active {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Socket Client {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int Available {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool Connected {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool ExclusiveAddressUse {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public LingerOption LingerState {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool NoDelay {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ReceiveBufferSize {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ReceiveTimeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int SendBufferSize {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int SendTimeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (IPEndPoint remoteEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (IPAddress address, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (IPAddress[] ipAddresses, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void EndConnect (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginConnect (IPAddress address, int port, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginConnect (IPAddress[] addresses, int port, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginConnect (string host, int port, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected virtual void Dispose (bool disposing)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		~TcpClient ()
+		{
+		}
+
+		public NetworkStream GetStream()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task ConnectAsync (IPAddress address, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task ConnectAsync (IPAddress[] addresses, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task ConnectAsync (string host, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 135 - 0
mcs/class/System/System.Net.Sockets/TcpListener.platformnotsupported.cs

@@ -0,0 +1,135 @@
+//
+// System.Net.Sockets.TcpListener.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Net;
+using System.Threading.Tasks;
+
+namespace System.Net.Sockets
+{
+	public class TcpListener
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.Sockets.TcpListener is not supported on the current platform.";
+
+		public TcpListener (int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpListener (IPEndPoint localEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpListener (IPAddress localaddr, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected bool Active {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public EndPoint LocalEndpoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Socket Server {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool ExclusiveAddressUse {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Socket AcceptSocket ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpClient AcceptTcpClient ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		~TcpListener ()
+		{
+		}
+
+		public bool Pending ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Start ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Start (int backlog)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginAcceptSocket (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginAcceptTcpClient (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Socket EndAcceptSocket (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public TcpClient EndAcceptTcpClient (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Stop ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<Socket> AcceptSocketAsync ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<TcpClient> AcceptTcpClientAsync ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 241 - 0
mcs/class/System/System.Net.Sockets/UdpClient.platformnotsupported.cs

@@ -0,0 +1,241 @@
+//
+// System.Net.Sockets.UdpClient.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Threading.Tasks;
+
+namespace System.Net.Sockets
+{
+	public class UdpClient : IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.Sockets.UdpClient is not supported on the current platform.";
+
+		public UdpClient ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public UdpClient(AddressFamily family)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public UdpClient (int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public UdpClient (IPEndPoint localEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public UdpClient (int port, AddressFamily family)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public UdpClient (string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (IPEndPoint endPoint)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (IPAddress addr, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Connect (string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void DropMulticastGroup (IPAddress multicastAddr)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void DropMulticastGroup (IPAddress multicastAddr, int ifindex)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void JoinMulticastGroup (IPAddress multicastAddr)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void JoinMulticastGroup (int ifindex, IPAddress multicastAddr)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void JoinMulticastGroup (IPAddress multicastAddr, int timeToLive)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void JoinMulticastGroup (IPAddress multicastAddr, IPAddress localAddress)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public byte [] Receive (ref IPEndPoint remoteEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public int Send (byte [] dgram, int bytes)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public int Send (byte [] dgram, int bytes, IPEndPoint endPoint)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public int Send (byte [] dgram, int bytes, string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginSend (byte[] datagram, int bytes, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginSend (byte[] datagram, int bytes, IPEndPoint endPoint, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginSend (byte[] datagram, int bytes, string hostname, int port, AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public int EndSend (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginReceive (AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public byte[] EndReceive (IAsyncResult asyncResult, ref IPEndPoint remoteEP)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected bool Active {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Socket Client {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int Available {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool DontFragment {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool EnableBroadcast {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool ExclusiveAddressUse {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool MulticastLoopback {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public short Ttl {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public void Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected virtual void Dispose (bool disposing)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		~UdpClient ()
+		{
+		}
+
+		public Task<UdpReceiveResult> ReceiveAsync ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<int> SendAsync (byte[] datagram, int bytes)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<int> SendAsync (byte[] datagram, int bytes, IPEndPoint endPoint)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<int> SendAsync (byte[] datagram, int bytes, string hostname, int port)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 98 - 0
mcs/class/System/System.Net.WebSockets/ClientWebSocket.platformnotsupported.cs

@@ -0,0 +1,98 @@
+//
+// ClientWebSocket.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace System.Net.WebSockets
+{
+	public class ClientWebSocket : WebSocket, IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.WebSockets.ClientWebSocket is not supported on the current platform.";
+
+		public ClientWebSocket ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override void Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override void Abort ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public ClientWebSocketOptions Options {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebSocketState State {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebSocketCloseStatus? CloseStatus {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string CloseStatusDescription {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string SubProtocol {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Task ConnectAsync (Uri uri, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Task SendAsync (ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Task<WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Task CloseAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Task CloseOutputAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 24 - 0
mcs/class/System/System.Net/Dns.cs

@@ -130,6 +130,9 @@ namespace System.Net {
 		[Obsolete ("Use BeginGetHostEntry instead")]
 		[Obsolete ("Use BeginGetHostEntry instead")]
 		public static IAsyncResult BeginGetHostByName (string hostName, AsyncCallback requestCallback, object stateObject)
 		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)
 			if (hostName == null)
 				throw new ArgumentNullException ("hostName");
 				throw new ArgumentNullException ("hostName");
 
 
@@ -140,11 +143,15 @@ namespace System.Net {
 
 
 			GetHostByNameCallback c = new GetHostByNameCallback (GetHostByName);
 			GetHostByNameCallback c = new GetHostByNameCallback (GetHostByName);
 			return c.BeginInvoke (hostName, requestCallback, stateObject);
 			return c.BeginInvoke (hostName, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		[Obsolete ("Use BeginGetHostEntry instead")]
 		[Obsolete ("Use BeginGetHostEntry instead")]
 		public static IAsyncResult BeginResolve (string hostName, AsyncCallback requestCallback, object stateObject)
 		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)
 			if (hostName == null)
 				throw new ArgumentNullException ("hostName");
 				throw new ArgumentNullException ("hostName");
 
 
@@ -155,6 +162,7 @@ namespace System.Net {
 
 
 			ResolveCallback c = new ResolveCallback (Resolve);
 			ResolveCallback c = new ResolveCallback (Resolve);
 			return c.BeginInvoke (hostName, requestCallback, stateObject);
 			return c.BeginInvoke (hostName, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		public static IAsyncResult BeginGetHostAddresses (string hostNameOrAddress, AsyncCallback requestCallback, object state)
 		public static IAsyncResult BeginGetHostAddresses (string hostNameOrAddress, AsyncCallback requestCallback, object state)
@@ -178,6 +186,9 @@ namespace System.Net {
 
 
 		public static IAsyncResult BeginGetHostEntry (string hostNameOrAddress, AsyncCallback requestCallback, object stateObject)
 		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)
 			if (hostNameOrAddress == null)
 				throw new ArgumentNullException ("hostName");
 				throw new ArgumentNullException ("hostName");
 			if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0")
 			if (hostNameOrAddress == "0.0.0.0" || hostNameOrAddress == "::0")
@@ -193,10 +204,14 @@ namespace System.Net {
 
 
 			GetHostEntryNameCallback c = new GetHostEntryNameCallback (GetHostEntry);
 			GetHostEntryNameCallback c = new GetHostEntryNameCallback (GetHostEntry);
 			return c.BeginInvoke (hostNameOrAddress, requestCallback, stateObject);
 			return c.BeginInvoke (hostNameOrAddress, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		public static IAsyncResult BeginGetHostEntry (IPAddress address, AsyncCallback requestCallback, object stateObject)
 		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)
 			if (address == null)
 				throw new ArgumentNullException ("address");
 				throw new ArgumentNullException ("address");
 
 
@@ -207,6 +222,7 @@ namespace System.Net {
 
 
 			GetHostEntryIPCallback c = new GetHostEntryIPCallback (GetHostEntry);
 			GetHostEntryIPCallback c = new GetHostEntryIPCallback (GetHostEntry);
 			return c.BeginInvoke (address, requestCallback, stateObject);
 			return c.BeginInvoke (address, requestCallback, stateObject);
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		[Obsolete ("Use EndGetHostEntry instead")]
 		[Obsolete ("Use EndGetHostEntry instead")]
@@ -409,6 +425,10 @@ namespace System.Net {
 		[Obsolete ("Use GetHostEntry instead")]
 		[Obsolete ("Use GetHostEntry instead")]
 		public static IPHostEntry GetHostByName (string hostName)
 		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)
 			if (hostName == null)
 				throw new ArgumentNullException ("hostName");
 				throw new ArgumentNullException ("hostName");
 			string h_name;
 			string h_name;
@@ -436,6 +456,9 @@ namespace System.Net {
 		[Obsolete ("Use GetHostEntry instead")]
 		[Obsolete ("Use GetHostEntry instead")]
 		public static IPHostEntry Resolve(string hostName) 
 		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)
 			if (hostName == null)
 				throw new ArgumentNullException ("hostName");
 				throw new ArgumentNullException ("hostName");
 
 
@@ -450,6 +473,7 @@ namespace System.Net {
 				ret =  GetHostByName(hostName);
 				ret =  GetHostByName(hostName);
 
 
 			return ret;
 			return ret;
+#endif // FEATURE_NO_BSD_SOCKETS
 		}
 		}
 
 
 		public static Task<IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress)
 		public static Task<IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress)

+ 39 - 0
mcs/class/System/System.Net/FtpRequestCreator.platformnotsupported.cs

@@ -0,0 +1,39 @@
+//
+// System.Net.FtpbRequestCreator.cs
+//
+// Authors:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Net
+{
+	class FtpRequestCreator : IWebRequestCreate
+	{
+		internal const string EXCEPTION_MESSAGE = "System.Net.FtpRequestCreator is not supported on the current platform.";
+		public WebRequest Create (Uri uri)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 182 - 0
mcs/class/System/System.Net/FtpWebRequest.platformnotsupported.cs

@@ -0,0 +1,182 @@
+//
+// System.Net.FtpWebRequest.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+
+namespace System.Net
+{
+	public sealed class FtpWebRequest : WebRequest
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.FtpWebRequest is not supported on the current platform.";
+
+		FtpWebRequest ()
+		{
+		}
+
+		public X509CertificateCollection ClientCertificates {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string ConnectionGroupName {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string ContentType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override long ContentLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public long ContentOffset {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override ICredentials Credentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+#if !MOBILE
+		public static new RequestCachePolicy DefaultCachePolicy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+#endif
+
+		public bool EnableSsl {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebHeaderCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool KeepAlive {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string Method {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool PreAuthenticate {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override IWebProxy Proxy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ReadWriteTimeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string RenameTo {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override Uri RequestUri {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public ServicePoint ServicePoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UsePassive {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool UseDefaultCredentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UseBinary {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override int Timeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override void Abort ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override WebResponse EndGetResponse (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override WebResponse GetResponse ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream EndGetRequestStream (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream GetRequestStream ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 91 - 0
mcs/class/System/System.Net/FtpWebResponse.platformnotsupported.cs

@@ -0,0 +1,91 @@
+//
+// System.Net.FtpWebResponse.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+
+namespace System.Net
+{
+	public class FtpWebResponse : WebResponse
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.FtpWebResponse is not supported on the current platform.";
+
+		FtpWebResponse ()
+		{
+		}
+
+		public override long ContentLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebHeaderCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override Uri ResponseUri {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DateTime LastModified {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string BannerMessage {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string WelcomeMessage {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string ExitMessage {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public FtpStatusCode StatusCode {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool SupportsHeaders {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string StatusDescription {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream GetResponseStream ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 128 - 0
mcs/class/System/System.Net/HttpListener.platformnotsupported.cs

@@ -0,0 +1,128 @@
+//
+// System.Net.HttpListener
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Threading.Tasks;
+
+namespace System.Net {
+	public sealed class HttpListener : IDisposable
+	{
+		internal const string EXCEPTION_MESSAGE = "System.Net.HttpListener is not supported on the current platform.";
+
+		public HttpListener ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal HttpListener (System.Security.Cryptography.X509Certificates.X509Certificate certificate, Mono.Net.Security.IMonoTlsProvider tlsProvider, Mono.Security.Interface.MonoTlsSettings tlsSettings)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public AuthenticationSchemes AuthenticationSchemes {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public AuthenticationSchemeSelector AuthenticationSchemeSelectorDelegate {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IgnoreWriteExceptions {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsListening {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public static bool IsSupported {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public HttpListenerPrefixCollection Prefixes {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Realm {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UnsafeConnectionNtlmAuthentication {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public void Abort ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IAsyncResult BeginGetContext (AsyncCallback callback, Object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public HttpListenerContext EndGetContext (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public HttpListenerContext GetContext ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Start ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Stop ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		void IDisposable.Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<HttpListenerContext> GetContextAsync ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 68 - 0
mcs/class/System/System.Net/HttpListenerContext.platformnotsupported.cs

@@ -0,0 +1,68 @@
+//
+// System.Net.HttpListenerContext
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Security.Principal;
+using System.Threading.Tasks;
+using System.Net.WebSockets;
+
+namespace System.Net {
+	public sealed class HttpListenerContext {
+		const string EXCEPTION_MESSAGE = "System.Net.HttpListenerContext is not supported on the current platform.";
+
+		HttpListenerContext ()
+		{
+		}
+
+		public HttpListenerRequest Request {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public HttpListenerResponse Response {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IPrincipal User {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment<byte> internalBuffer)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 93 - 0
mcs/class/System/System.Net/HttpListenerPrefixCollection.platformnotsupported.cs

@@ -0,0 +1,93 @@
+//
+// System.Net.HttpListenerPrefixCollection.cs
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Collections.Generic;
+
+namespace System.Net {
+	public class HttpListenerPrefixCollection : ICollection<string>, IEnumerable<string>, IEnumerable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.HttpListenerPrefixCollection is not supported on the current platform.";
+
+		HttpListenerPrefixCollection ()
+		{
+		}
+
+		public int Count {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsReadOnly {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsSynchronized {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public void Add (string uriPrefix)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Clear ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public bool Contains (string uriPrefix)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void CopyTo (string [] array, int offset)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void CopyTo (Array array, int offset)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public IEnumerator<string> GetEnumerator ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		IEnumerator IEnumerable.GetEnumerator ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public bool Remove (string uriPrefix)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 180 - 0
mcs/class/System/System.Net/HttpListenerRequest.platformnotsupported.cs

@@ -0,0 +1,180 @@
+//
+// System.Net.HttpListenerRequest
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.Specialized;
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace System.Net {
+	public sealed class HttpListenerRequest
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.HttpListenerRequest is not supported on the current platform.";
+
+		HttpListenerRequest ()
+		{
+		}
+
+		public string [] AcceptTypes {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ClientCertificateError {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Encoding ContentEncoding {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public long ContentLength64 {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string ContentType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public CookieCollection Cookies {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool HasEntityBody {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public NameValueCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string HttpMethod {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Stream InputStream {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsAuthenticated {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsLocal {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsSecureConnection {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool KeepAlive {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IPEndPoint LocalEndPoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Version ProtocolVersion {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public NameValueCollection QueryString {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string RawUrl {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IPEndPoint RemoteEndPoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Guid RequestTraceIdentifier {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Uri Url {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Uri UrlReferrer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string UserAgent {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string UserHostAddress {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string UserHostName {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string [] UserLanguages {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public IAsyncResult BeginGetClientCertificate (AsyncCallback requestCallback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public X509Certificate2 EndGetClientCertificate (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public X509Certificate2 GetClientCertificate ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public string ServiceName {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public TransportContext TransportContext {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool IsWebSocketRequest {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Task<X509Certificate2> GetClientCertificateAsync ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 0 - 58
mcs/class/System/System.Net/HttpListenerResponse.cs

@@ -517,64 +517,6 @@ namespace System.Net {
 			cookies.Add (cookie);
 			cookies.Add (cookie);
 		}
 		}
 	}
 	}
-
-	// do not inline into HttpListenerResponse as this recursively brings everything that's 
-	// reachable by IDisposable.Dispose (and that's quite a lot in this case). 
-	static class HttpListenerResponseHelper {
-
-		internal static string GetStatusDescription (int code)
-		{
-			switch (code){
-			case 100: return "Continue";
-			case 101: return "Switching Protocols";
-			case 102: return "Processing";
-			case 200: return "OK";
-			case 201: return "Created";
-			case 202: return "Accepted";
-			case 203: return "Non-Authoritative Information";
-			case 204: return "No Content";
-			case 205: return "Reset Content";
-			case 206: return "Partial Content";
-			case 207: return "Multi-Status";
-			case 300: return "Multiple Choices";
-			case 301: return "Moved Permanently";
-			case 302: return "Found";
-			case 303: return "See Other";
-			case 304: return "Not Modified";
-			case 305: return "Use Proxy";
-			case 307: return "Temporary Redirect";
-			case 400: return "Bad Request";
-			case 401: return "Unauthorized";
-			case 402: return "Payment Required";
-			case 403: return "Forbidden";
-			case 404: return "Not Found";
-			case 405: return "Method Not Allowed";
-			case 406: return "Not Acceptable";
-			case 407: return "Proxy Authentication Required";
-			case 408: return "Request Timeout";
-			case 409: return "Conflict";
-			case 410: return "Gone";
-			case 411: return "Length Required";
-			case 412: return "Precondition Failed";
-			case 413: return "Request Entity Too Large";
-			case 414: return "Request-Uri Too Long";
-			case 415: return "Unsupported Media Type";
-			case 416: return "Requested Range Not Satisfiable";
-			case 417: return "Expectation Failed";
-			case 422: return "Unprocessable Entity";
-			case 423: return "Locked";
-			case 424: return "Failed Dependency";
-			case 500: return "Internal Server Error";
-			case 501: return "Not Implemented";
-			case 502: return "Bad Gateway";
-			case 503: return "Service Unavailable";
-			case 504: return "Gateway Timeout";
-			case 505: return "Http Version Not Supported";
-			case 507: return "Insufficient Storage";
-			}
-			return "";
-		}
-	}
 }
 }
 #endif
 #endif
 
 

+ 150 - 0
mcs/class/System/System.Net/HttpListenerResponse.platformnotsupported.cs

@@ -0,0 +1,150 @@
+//
+// System.Net.HttpListenerResponse
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Text;
+
+namespace System.Net {
+	public sealed class HttpListenerResponse : IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.HttpListenerResponse is not supported on the current platform.";
+
+		HttpListenerResponse ()
+		{
+		}
+
+		public Encoding ContentEncoding {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public long ContentLength64 {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string ContentType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public CookieCollection Cookies {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public WebHeaderCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool KeepAlive {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Stream OutputStream {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Version ProtocolVersion {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string RedirectLocation {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool SendChunked {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int StatusCode {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string StatusDescription {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		void IDisposable.Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Abort ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddHeader (string name, string value)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AppendCookie (Cookie cookie)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AppendHeader (string name, string value)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Close (byte [] responseEntity, bool willBlock)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void CopyFrom (HttpListenerResponse templateResponse)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void Redirect (string url)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void SetCookie (Cookie cookie)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 88 - 0
mcs/class/System/System.Net/HttpListenerResponseHelper.cs

@@ -0,0 +1,88 @@
+//
+// System.Net.HttpListenerResponseHelper
+//
+// Author:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.Net {
+	// do not inline into HttpListenerResponse as this recursively brings everything that's
+	// reachable by IDisposable.Dispose (and that's quite a lot in this case).
+	static class HttpListenerResponseHelper {
+
+		internal static string GetStatusDescription (int code)
+		{
+			switch (code){
+			case 100: return "Continue";
+			case 101: return "Switching Protocols";
+			case 102: return "Processing";
+			case 200: return "OK";
+			case 201: return "Created";
+			case 202: return "Accepted";
+			case 203: return "Non-Authoritative Information";
+			case 204: return "No Content";
+			case 205: return "Reset Content";
+			case 206: return "Partial Content";
+			case 207: return "Multi-Status";
+			case 300: return "Multiple Choices";
+			case 301: return "Moved Permanently";
+			case 302: return "Found";
+			case 303: return "See Other";
+			case 304: return "Not Modified";
+			case 305: return "Use Proxy";
+			case 307: return "Temporary Redirect";
+			case 400: return "Bad Request";
+			case 401: return "Unauthorized";
+			case 402: return "Payment Required";
+			case 403: return "Forbidden";
+			case 404: return "Not Found";
+			case 405: return "Method Not Allowed";
+			case 406: return "Not Acceptable";
+			case 407: return "Proxy Authentication Required";
+			case 408: return "Request Timeout";
+			case 409: return "Conflict";
+			case 410: return "Gone";
+			case 411: return "Length Required";
+			case 412: return "Precondition Failed";
+			case 413: return "Request Entity Too Large";
+			case 414: return "Request-Uri Too Long";
+			case 415: return "Unsupported Media Type";
+			case 416: return "Requested Range Not Satisfiable";
+			case 417: return "Expectation Failed";
+			case 422: return "Unprocessable Entity";
+			case 423: return "Locked";
+			case 424: return "Failed Dependency";
+			case 500: return "Internal Server Error";
+			case 501: return "Not Implemented";
+			case 502: return "Bad Gateway";
+			case 503: return "Service Unavailable";
+			case 504: return "Gateway Timeout";
+			case 505: return "Http Version Not Supported";
+			case 507: return "Insufficient Storage";
+			}
+			return "";
+		}
+	}
+}

+ 460 - 0
mcs/class/System/System.Net/HttpWebRequest.platformnotsupported.cs

@@ -0,0 +1,460 @@
+//
+// System.Net.HttpWebRequest
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.X509Certificates;
+
+namespace System.Net
+{
+	[Serializable]
+	public class HttpWebRequest : WebRequest, ISerializable
+	{
+		internal const string EXCEPTION_MESSAGE = "System.Net.HttpWebRequest is not supported on the current platform.";
+
+		internal WebConnection WebConnection {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+#if MOBILE
+		public
+#else
+		internal
+#endif
+		HttpWebRequest (Uri uri)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal HttpWebRequest (Uri uri, object /* IMonoTlsProvider */ tlsProvider, object /* MonoTlsSettings */ settings = null)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected HttpWebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public string Accept {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Uri Address {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool AllowAutoRedirect {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool AllowWriteStreamBuffering {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool AllowReadStreamBuffering {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DecompressionMethods AutomaticDecompression {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal bool InternalAllowBuffering {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal Mono.Net.Security.IMonoTlsProvider TlsProvider {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal Mono.Security.Interface.MonoTlsSettings TlsSettings {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public X509CertificateCollection ClientCertificates {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Connection {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string ConnectionGroupName {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override long ContentLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal long InternalContentLength {
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string ContentType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public HttpContinueDelegate ContinueDelegate {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual CookieContainer CookieContainer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override ICredentials Credentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DateTime Date {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+#if !MOBILE
+		public static new RequestCachePolicy DefaultCachePolicy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+#endif
+
+		public static int DefaultMaximumErrorResponseLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Expect {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool HaveResponse {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebHeaderCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Host {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DateTime IfModifiedSince {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool KeepAlive {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int MaximumAutomaticRedirections {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int MaximumResponseHeadersLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public static int DefaultMaximumResponseHeadersLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ReadWriteTimeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public int ContinueTimeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string MediaType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string Method {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool Pipelined {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool PreAuthenticate {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Version ProtocolVersion {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override IWebProxy Proxy {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Referer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override Uri RequestUri {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool SendChunked {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public ServicePoint ServicePoint {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal ServicePoint ServicePointNoLock {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual bool SupportsCookieContainer {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override int Timeout {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string TransferEncoding {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool UseDefaultCredentials {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string UserAgent {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public bool UnsafeAuthenticatedConnectionSharing {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal bool ExpectContinue {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal ServerCertValidationCallback ServerCertValidationCallback {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal Uri AuthUri {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public RemoteCertificateValidationCallback ServerCertificateValidationCallback {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public void AddRange (int range)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (int from, int to)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (string rangeSpecifier, int range)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (string rangeSpecifier, int from, int to)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (long range)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (long from, long to)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (string rangeSpecifier, long range)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public void AddRange (string rangeSpecifier, long from, long to)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream EndGetRequestStream (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream GetRequestStream()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override WebResponse EndGetResponse (IAsyncResult asyncResult)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public Stream EndGetRequestStream (IAsyncResult asyncResult, out TransportContext transportContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override WebResponse GetResponse()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal bool FinishedReading {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal bool Aborted {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override void Abort ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void DoContinueDelegate (int statusCode, WebHeaderCollection headers)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void SetWriteStreamError (WebExceptionStatus status, Exception exc)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal byte[] GetRequestHeaders ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void SetWriteStream (WebConnectionStream stream)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void SetResponseData (WebConnectionData data)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void SetResponseError (WebExceptionStatus status, Exception e, string where)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal bool ReuseConnection {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		internal WebConnection StoredConnection {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+	}
+}

+ 147 - 0
mcs/class/System/System.Net/HttpWebResponse.platformnotsupported.cs

@@ -0,0 +1,147 @@
+//
+// System.Net.HttpWebResponse
+//
+// Author:
+//	Rolf Bjarne Kvinge <[email protected]>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace System.Net
+{
+	[Serializable]
+	public class HttpWebResponse : WebResponse, ISerializable, IDisposable
+	{
+		const string EXCEPTION_MESSAGE = "System.Net.HttpWebResponse is not supported on the current platform.";
+
+		[Obsolete ("Serialization is obsoleted for this type", false)]
+		protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public string CharacterSet {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string ContentEncoding {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override long ContentLength {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override string ContentType {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual CookieCollection Cookies {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+			set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override WebHeaderCollection Headers {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		[MonoTODO]
+		public override bool IsMutuallyAuthenticated {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public DateTime LastModified {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual string Method {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public Version ProtocolVersion {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override Uri ResponseUri {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string Server {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual HttpStatusCode StatusCode {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public virtual string StatusDescription {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public override bool SupportsHeaders {
+			get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
+		}
+
+		public string GetResponseHeader (string headerName)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		internal void ReadAll ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override Stream GetResponseStream ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		public override void Close ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		void IDisposable.Dispose ()
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+
+		protected override void Dispose (bool disposing)
+		{
+			throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+		}
+	}
+}

+ 1 - 0
mcs/class/System/System.dll.sources

@@ -269,6 +269,7 @@ System.Net/HttpListener.cs
 System.Net/HttpListenerPrefixCollection.cs
 System.Net/HttpListenerPrefixCollection.cs
 System.Net/HttpListenerRequest.cs
 System.Net/HttpListenerRequest.cs
 System.Net/HttpListenerResponse.cs
 System.Net/HttpListenerResponse.cs
+System.Net/HttpListenerResponseHelper.cs
 System.Net/HttpListenerTimeoutManager.cs
 System.Net/HttpListenerTimeoutManager.cs
 System.Net/HttpRequestCreator.cs
 System.Net/HttpRequestCreator.cs
 System.Net/HttpStreamAsyncResult.cs
 System.Net/HttpStreamAsyncResult.cs

+ 75 - 3
mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs

@@ -16,16 +16,15 @@ using System.Threading;
 namespace MonoTests.System.Net.Mail
 namespace MonoTests.System.Net.Mail
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class SmtpClientTest
 	public class SmtpClientTest
 	{
 	{
-		SmtpClient smtp;
+		SmtpClient _smtp;
+		SmtpClient smtp { get { return _smtp ?? (_smtp = new SmtpClient ()); } }
 		string tempFolder;
 		string tempFolder;
 		
 		
 		[SetUp]
 		[SetUp]
 		public void GetReady ()
 		public void GetReady ()
 		{
 		{
-			smtp = new SmtpClient ();
 			tempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
 			tempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
 			if (Directory.Exists (tempFolder))
 			if (Directory.Exists (tempFolder))
 				Directory.Delete (tempFolder, true);
 				Directory.Delete (tempFolder, true);
@@ -40,12 +39,18 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Credentials_Default ()
 		public void Credentials_Default ()
 		{
 		{
 			Assert.IsNull (smtp.Credentials);
 			Assert.IsNull (smtp.Credentials);
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DeliveryMethod ()
 		public void DeliveryMethod ()
 		{
 		{
 			Assert.AreEqual (SmtpDeliveryMethod.Network, smtp.DeliveryMethod, "#1");
 			Assert.AreEqual (SmtpDeliveryMethod.Network, smtp.DeliveryMethod, "#1");
@@ -61,6 +66,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void EnableSsl ()
 		public void EnableSsl ()
 		{
 		{
 			Assert.IsFalse (smtp.EnableSsl, "#1");
 			Assert.IsFalse (smtp.EnableSsl, "#1");
@@ -71,6 +79,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Host ()
 		public void Host ()
 		{
 		{
 			smtp.Host = "127.0.0.1";
 			smtp.Host = "127.0.0.1";
@@ -87,6 +98,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Host_Value_Null ()
 		public void Host_Value_Null ()
 		{
 		{
 			try {
 			try {
@@ -101,6 +115,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Host_Value_Empty ()
 		public void Host_Value_Empty ()
 		{
 		{
 			try {
 			try {
@@ -116,6 +133,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PickupDirectoryLocation ()
 		public void PickupDirectoryLocation ()
 		{
 		{
 			Assert.IsNull (smtp.PickupDirectoryLocation, "#1");
 			Assert.IsNull (smtp.PickupDirectoryLocation, "#1");
@@ -132,6 +152,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Port ()
 		public void Port ()
 		{
 		{
 			Assert.AreEqual (25, smtp.Port, "#1");
 			Assert.AreEqual (25, smtp.Port, "#1");
@@ -142,6 +165,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Port_Value_Invalid ()
 		public void Port_Value_Invalid ()
 		{
 		{
 			// zero
 			// zero
@@ -168,6 +194,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Message_Null ()
 		public void Send_Message_Null ()
 		{
 		{
 			try {
 			try {
@@ -182,6 +211,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Network_Host_Null ()
 		public void Send_Network_Host_Null ()
 		{
 		{
 			try {
 			try {
@@ -197,6 +229,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_Network_Host_Whitespace ()
 		public void Send_Network_Host_Whitespace ()
 		{
 		{
 			smtp.Host = " \r\n ";
 			smtp.Host = " \r\n ";
@@ -213,6 +248,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory ()
 		public void Send_SpecifiedPickupDirectory ()
 		{
 		{
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -226,6 +264,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_DirectoryNotFound ()
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_DirectoryNotFound ()
 		{
 		{
 			Directory.Delete (tempFolder);
 			Directory.Delete (tempFolder);
@@ -253,6 +294,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Empty ()
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Empty ()
 		{
 		{
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -272,6 +316,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_IllegalChars ()
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_IllegalChars ()
 		{
 		{
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -297,6 +344,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_NotAbsolute ()
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_NotAbsolute ()
 		{
 		{
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -316,6 +366,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Null ()
 		public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Null ()
 		{
 		{
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
 			smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -334,6 +387,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Timeout ()
 		public void Timeout ()
 		{
 		{
 			Assert.AreEqual (100000, smtp.Timeout, "#1");
 			Assert.AreEqual (100000, smtp.Timeout, "#1");
@@ -344,19 +400,29 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
+#endif
 		public void Timeout_Value_Negative ()
 		public void Timeout_Value_Negative ()
 		{
 		{
 			smtp.Timeout = -1;
 			smtp.Timeout = -1;
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UseDefaultCredentials_Default ()
 		public void UseDefaultCredentials_Default ()
 		{
 		{
 			Assert.IsFalse (smtp.UseDefaultCredentials);
 			Assert.IsFalse (smtp.UseDefaultCredentials);
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Deliver ()
 		public void Deliver ()
 		{
 		{
 			var server = new SmtpServer ();
 			var server = new SmtpServer ();
@@ -373,6 +439,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Deliver_Envelope ()
 		public void Deliver_Envelope ()
 		{
 		{
 			var server = new SmtpServer ();
 			var server = new SmtpServer ();
@@ -391,6 +460,9 @@ namespace MonoTests.System.Net.Mail
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Deliver_Async ()
 		public void Deliver_Async ()
 		{
 		{
 			// SmtpClient uses BackgroundWorker and listens for the RunWorkerCompleted
 			// SmtpClient uses BackgroundWorker and listens for the RunWorkerCompleted

Разница между файлами не показана из-за своего большого размера
+ 0 - 1
mcs/class/System/Test/System.Net.Security/SslStreamTest.cs


+ 8 - 1
mcs/class/System/Test/System.Net.Sockets/NetworkStreamTest.cs

@@ -16,12 +16,16 @@ using NUnit.Framework;
 namespace MonoTests.System.Net.Sockets
 namespace MonoTests.System.Net.Sockets
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class NetworkStreamTest
 	public class NetworkStreamTest
 	{
 	{
 	        [Test]
 	        [Test]
 		// See bug #371923
 		// See bug #371923
+
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException(typeof(IOException))]
 		[ExpectedException(typeof(IOException))]
+#endif
 		public void NetworkStreamConnection ()
 		public void NetworkStreamConnection ()
 		{
 		{
 			IPEndPoint ipe = new IPEndPoint(Dns.GetHostEntry ("www.google.com").AddressList [0], 80);
 			IPEndPoint ipe = new IPEndPoint(Dns.GetHostEntry ("www.google.com").AddressList [0], 80);
@@ -31,6 +35,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadTimeout ()
 		public void ReadTimeout ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,

+ 31 - 15
mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs

@@ -6,10 +6,12 @@ using NUnit.Framework;
 namespace MonoTests.System.Net.Sockets
 namespace MonoTests.System.Net.Sockets
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class SocketAcceptAsyncTest
 	public class SocketAcceptAsyncTest
 	{
 	{
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
 		public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
 		{
 		{
 			var readyEvent = new ManualResetEvent(false);
 			var readyEvent = new ManualResetEvent(false);
@@ -19,27 +21,41 @@ namespace MonoTests.System.Net.Sockets
 			var serverSocket = new Socket(
 			var serverSocket = new Socket(
 					AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 					AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 			Socket acceptedSocket = null;
 			Socket acceptedSocket = null;
-
+			Exception ex = null;
 			ThreadPool.QueueUserWorkItem(_ =>
 			ThreadPool.QueueUserWorkItem(_ =>
 			{
 			{
-				listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
-				listenSocket.Listen(1);
-
-				var asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
-				asyncEventArgs.Completed += (s, e) =>
-				{
-					acceptedSocket = e.AcceptSocket;
-					mainEvent.Set();
-				};
+				SocketAsyncEventArgs asyncEventArgs;
+				try {
+					listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
+					listenSocket.Listen(1);
 
 
-				readyEvent.Set();
+					asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
+					asyncEventArgs.Completed += (s, e) =>
+					{
+						acceptedSocket = e.AcceptSocket;
+						mainEvent.Set();
+					};
 
 
-				if (listenSocket.AcceptAsync(asyncEventArgs))
+				} catch (Exception e) {
+					ex = e;
 					return;
 					return;
-				acceptedSocket = asyncEventArgs.AcceptSocket;
-				mainEvent.Set();
+				} finally {
+					readyEvent.Set();
+				}
+
+				try {
+					if (listenSocket.AcceptAsync(asyncEventArgs))
+						return;
+					acceptedSocket = asyncEventArgs.AcceptSocket;
+				} catch (Exception e) {
+					ex = e;
+				} finally {
+					mainEvent.Set();
+				}
 			});
 			});
 			Assert.IsTrue(readyEvent.WaitOne(1500));
 			Assert.IsTrue(readyEvent.WaitOne(1500));
+			if (ex != null)
+				throw ex;
 
 
 			var clientSocket = new Socket(
 			var clientSocket = new Socket(
 				AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 				AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

+ 24 - 15
mcs/class/System/Test/System.Net.Sockets/SocketAsyncTest.cs

@@ -8,7 +8,6 @@ using NUnit.Framework;
 namespace MonoTests.System.Net.Sockets
 namespace MonoTests.System.Net.Sockets
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class SocketAsyncTest
 	public class SocketAsyncTest
 	{
 	{
 		Socket serverSocket;
 		Socket serverSocket;
@@ -17,8 +16,7 @@ namespace MonoTests.System.Net.Sockets
 		ManualResetEvent mainEvent;
 		ManualResetEvent mainEvent;
 		Exception error;
 		Exception error;
 
 
-		[TestFixtureSetUp]
-		public void SetUp ()
+		void SetUp ()
 		{
 		{
 			readyEvent = new ManualResetEvent (false);
 			readyEvent = new ManualResetEvent (false);
 			mainEvent = new ManualResetEvent (false);
 			mainEvent = new ManualResetEvent (false);
@@ -26,6 +24,9 @@ namespace MonoTests.System.Net.Sockets
 			ThreadPool.QueueUserWorkItem (_ => DoWork ());
 			ThreadPool.QueueUserWorkItem (_ => DoWork ());
 			readyEvent.WaitOne ();
 			readyEvent.WaitOne ();
 
 
+			if (error != null)
+				throw error;
+
 			clientSocket = new Socket (
 			clientSocket = new Socket (
 				AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 				AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 			clientSocket.Connect (serverSocket.LocalEndPoint);
 			clientSocket.Connect (serverSocket.LocalEndPoint);
@@ -43,18 +44,22 @@ namespace MonoTests.System.Net.Sockets
 
 
 		void DoWork ()
 		void DoWork ()
 		{
 		{
-			serverSocket = new Socket (
-				AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-			serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
-			serverSocket.Listen (1);
-
-			var async = new SocketAsyncEventArgs ();
-			async.Completed += (s,e) => OnAccepted (e);
-
-			readyEvent.Set ();
-
-			if (!serverSocket.AcceptAsync (async))
-				OnAccepted (async);
+			try {
+				serverSocket = new Socket (
+					AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+				serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
+				serverSocket.Listen (1);
+
+				var async = new SocketAsyncEventArgs ();
+				async.Completed += (s,e) => OnAccepted (e);
+
+				if (!serverSocket.AcceptAsync (async))
+					OnAccepted (async);
+			} catch (Exception e) {
+				error = e;
+			} finally {
+				readyEvent.Set ();
+			}
 		}
 		}
 
 
 		void OnAccepted (SocketAsyncEventArgs e)
 		void OnAccepted (SocketAsyncEventArgs e)
@@ -93,8 +98,12 @@ namespace MonoTests.System.Net.Sockets
 
 
 		[Test]
 		[Test]
 		[Category("Test")]
 		[Category("Test")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SendAsync ()
 		public void SendAsync ()
 		{
 		{
+			SetUp ();
 			var buffer = new byte [] { 0x12, 0x34, 0x56, 0x78 };
 			var buffer = new byte [] { 0x12, 0x34, 0x56, 0x78 };
 			var m = new ManualResetEvent (false);
 			var m = new ManualResetEvent (false);
 			var e = new SocketAsyncEventArgs ();
 			var e = new SocketAsyncEventArgs ();

+ 204 - 1
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs

@@ -28,7 +28,6 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net.Sockets
 namespace MonoTests.System.Net.Sockets
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class SocketTest
 	public class SocketTest
 	{
 	{
 		// note: also used in SocketCas tests
 		// note: also used in SocketCas tests
@@ -36,6 +35,9 @@ namespace MonoTests.System.Net.Sockets
 		public const int BogusPort = 23483;
 		public const int BogusPort = 23483;
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectIPAddressAny ()
 		public void ConnectIPAddressAny ()
 		{
 		{
 			IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
 			IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ());
@@ -86,6 +88,9 @@ namespace MonoTests.System.Net.Sockets
 
 
 		[Test]
 		[Test]
 		[Category ("InetAccess")]
 		[Category ("InetAccess")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BogusEndConnect ()
 		public void BogusEndConnect ()
 		{
 		{
 			IPAddress ipOne = IPAddress.Parse (BogusAddress);
 			IPAddress ipOne = IPAddress.Parse (BogusAddress);
@@ -156,6 +161,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AcceptBlockingStatus()
 		public void AcceptBlockingStatus()
 		{
 		{
 			bool block;
 			bool block;
@@ -200,6 +208,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectFailAsync ()
 		public void ConnectFailAsync ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -222,6 +233,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOptionBoolean ()
 		public void SetSocketOptionBoolean ()
 		{
 		{
 			IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
 			IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
@@ -233,6 +247,9 @@ namespace MonoTests.System.Net.Sockets
 			}
 			}
 		}
 		}
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestSelect1 ()
 		public void TestSelect1 ()
 		{
 		{
 			Socket srv = CreateServer (NetworkHelpers.FindFreePort ());
 			Socket srv = CreateServer (NetworkHelpers.FindFreePort ());
@@ -370,7 +387,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed19 ()
 		public void Disposed19 ()
 		{
 		{
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -381,7 +402,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed20 ()
 		public void Disposed20 ()
 		{
 		{
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -392,7 +417,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed21 ()
 		public void Disposed21 ()
 		{
 		{
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -403,7 +432,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed22 ()
 		public void Disposed22 ()
 		{
 		{
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
 			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -424,6 +457,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetHashCodeTest ()
 		public void GetHashCodeTest ()
 		{
 		{
 			Socket server = new Socket (AddressFamily.InterNetwork,
 			Socket server = new Socket (AddressFamily.InterNetwork,
@@ -459,6 +495,7 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+		[Category ("RequiresBSDSockets")] // This verifies particular error codes, which we don't care about when nothing's working anyway.
 		public void SocketErrorTest ()
 		public void SocketErrorTest ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -700,6 +737,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void IsBoundTcp ()
 		public void IsBoundTcp ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -732,6 +772,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void IsBoundUdp ()
 		public void IsBoundUdp ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1304,7 +1347,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof(InvalidOperationException))]
 		[ExpectedException (typeof(InvalidOperationException))]
+#endif
 		public void BeginAcceptNotListening ()
 		public void BeginAcceptNotListening ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1319,6 +1366,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAccept ()
 		public void BeginAccept ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1386,6 +1436,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAcceptData ()
 		public void BeginAcceptData ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1450,6 +1503,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAcceptSocketUdp ()
 		public void BeginAcceptSocketUdp ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1477,6 +1533,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAcceptSocketBound ()
 		public void BeginAcceptSocketBound ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1508,6 +1567,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAcceptSocket ()
 		public void BeginAcceptSocket ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1589,6 +1651,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginAcceptSocketAccClosed ()
 		public void BeginAcceptSocketAccClosed ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1638,6 +1703,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectAddressPort ()
 		public void BeginConnectAddressPort ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1687,6 +1755,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectAddressPortListen ()
 		public void BeginConnectAddressPortListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1781,6 +1852,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectMultiple2 ()
 		public void BeginConnectMultiple2 ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1853,6 +1927,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectMultipleListen ()
 		public void BeginConnectMultipleListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1917,6 +1994,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectHostPortListen ()
 		public void BeginConnectHostPortListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -1984,6 +2064,9 @@ namespace MonoTests.System.Net.Sockets
 		
 		
 		[Test]
 		[Test]
 		[Category ("NotDotNet")] // "Needs XP or later"
 		[Category ("NotDotNet")] // "Needs XP or later"
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginDisconnect ()
 		public void BeginDisconnect ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2080,6 +2163,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BindTwice ()
 		public void BindTwice ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2103,6 +2189,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Close ()
 		public void Close ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2131,6 +2220,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectAddressPort ()
 		public void ConnectAddressPort ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2171,6 +2263,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectAddressPortListen ()
 		public void ConnectAddressPortListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2257,6 +2352,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectMultiple2 ()
 		public void ConnectMultiple2 ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2314,6 +2412,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectMultipleListen ()
 		public void ConnectMultipleListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2376,6 +2477,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectHostPortListen ()
 		public void ConnectHostPortListen ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2414,7 +2518,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof(ObjectDisposedException))]
 		[ExpectedException (typeof(ObjectDisposedException))]
+#endif
 		public void ConnectHostPortClosed ()
 		public void ConnectHostPortClosed ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2428,6 +2536,9 @@ namespace MonoTests.System.Net.Sockets
 		
 		
 		[Test]
 		[Test]
 		[Category ("NotDotNet")] // "Needs XP or later"
 		[Category ("NotDotNet")] // "Needs XP or later"
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Disconnect ()
 		public void Disconnect ()
 		{
 		{
 			Socket sock = new Socket (AddressFamily.InterNetwork,
 			Socket sock = new Socket (AddressFamily.InterNetwork,
@@ -2485,6 +2596,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveGeneric ()
 		public void ReceiveGeneric ()
 		{
 		{
 			int i;
 			int i;
@@ -2542,6 +2656,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SendGeneric ()
 		public void SendGeneric ()
 		{
 		{
 			int i;
 			int i;
@@ -2700,6 +2817,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseWhileReceiving ()
 		public void CloseWhileReceiving ()
 		{
 		{
 			CWRSocket = new Socket (AddressFamily.InterNetwork,
 			CWRSocket = new Socket (AddressFamily.InterNetwork,
@@ -3069,6 +3189,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom1_Buffer_Null ()
 		public void ReceiveFrom1_Buffer_Null ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3110,6 +3233,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom1_Socket_Closed ()
 		public void ReceiveFrom1_Socket_Closed ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3130,6 +3256,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom2_Buffer_Null ()
 		public void ReceiveFrom2_Buffer_Null ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3171,6 +3300,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom2_Socket_Closed ()
 		public void ReceiveFrom2_Socket_Closed ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3191,6 +3323,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom3_Buffer_Null ()
 		public void ReceiveFrom3_Buffer_Null ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3233,6 +3368,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom3_Size_OutOfRange ()
 		public void ReceiveFrom3_Size_OutOfRange ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -3274,6 +3412,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom3_Socket_Closed ()
 		public void ReceiveFrom3_Socket_Closed ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3295,6 +3436,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom4_Buffer_Null ()
 		public void ReceiveFrom4_Buffer_Null ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3314,6 +3458,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom4_Offset_OutOfRange ()
 		public void ReceiveFrom4_Offset_OutOfRange ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -3377,6 +3524,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom4_Size_OutOfRange ()
 		public void ReceiveFrom4_Size_OutOfRange ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -3435,6 +3585,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, ref EndPoint)
 		[Test] // ReceiveFrom (Byte [], Int32, Int32, SocketFlags, ref EndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveFrom4_Socket_Closed ()
 		public void ReceiveFrom4_Socket_Closed ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
@@ -3457,6 +3610,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveRemoteClosed ()
 		public void ReceiveRemoteClosed ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -3484,6 +3640,9 @@ namespace MonoTests.System.Net.Sockets
 		//
 		//
 		// Test case for bug #471580
 		// Test case for bug #471580
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UdpDoubleBind ()
 		public void UdpDoubleBind ()
 		{
 		{
 			using (Socket s = new Socket (AddressFamily.InterNetwork,
 			using (Socket s = new Socket (AddressFamily.InterNetwork,
@@ -3517,6 +3676,9 @@ namespace MonoTests.System.Net.Sockets
 
 
 		// Test case for bug #31557
 		// Test case for bug #31557
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TcpDoubleBind ()
 		public void TcpDoubleBind ()
 		{
 		{
 			using (Socket s = new Socket (AddressFamily.InterNetwork,
 			using (Socket s = new Socket (AddressFamily.InterNetwork,
@@ -3755,6 +3917,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_AddMembershipIPv4_IPv6MulticastOption ()
 		public void SetSocketOption3_AddMembershipIPv4_IPv6MulticastOption ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
@@ -3777,6 +3942,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_AddMembershipIPv4_MulticastOption ()
 		public void SetSocketOption3_AddMembershipIPv4_MulticastOption ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
@@ -3813,6 +3981,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_AddMembershipIPv6_IPv6MulticastOption ()
 		public void SetSocketOption3_AddMembershipIPv6_IPv6MulticastOption ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -3828,6 +3999,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_AddMembershipIPv6_MulticastOption ()
 		public void SetSocketOption3_AddMembershipIPv6_MulticastOption ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -3982,6 +4156,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_DropMembershipIPv4_IPv6MulticastOption ()
 		public void SetSocketOption3_DropMembershipIPv4_IPv6MulticastOption ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
@@ -4006,6 +4183,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_DropMembershipIPv4_MulticastOption ()
 		public void SetSocketOption3_DropMembershipIPv4_MulticastOption ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
 			IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250");
@@ -4046,6 +4226,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_DropMembershipIPv6_IPv6MulticastOption ()
 		public void SetSocketOption3_DropMembershipIPv6_IPv6MulticastOption ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -4064,6 +4247,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
 		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SetSocketOption3_DropMembershipIPv6_MulticastOption ()
 		public void SetSocketOption3_DropMembershipIPv6_MulticastOption ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -4150,6 +4336,7 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+		[Category ("RequiresBSDSockets")] // on watchOS device this happens: System.Net.Sockets.SocketException : The requested address is not valid in this context. This situation is too complex to detect and throw a PlatformNotSupportedException, so just ignore it.
 		public void SetSocketOption_MulticastInterfaceIndex_Any ()
 		public void SetSocketOption_MulticastInterfaceIndex_Any ()
 		{
 		{
 			IPAddress ip = IPAddress.Parse ("239.255.255.250");
 			IPAddress ip = IPAddress.Parse ("239.255.255.250");
@@ -4162,6 +4349,7 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+		[Category ("RequiresBSDSockets")] // on watchOS device this happens: System.Net.Sockets.SocketException : The requested address is not valid in this context. This situation is too complex to detect and throw a PlatformNotSupportedException, so just ignore it.
 		public void SetSocketOption_MulticastInterfaceIndex_Loopback ()
 		public void SetSocketOption_MulticastInterfaceIndex_Loopback ()
 		{
 		{
 			IPAddress ip = IPAddress.Parse ("239.255.255.250");
 			IPAddress ip = IPAddress.Parse ("239.255.255.250");
@@ -4198,6 +4386,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Shutdown_NoConnect ()
 		public void Shutdown_NoConnect ()
 		{
 		{
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
@@ -4294,6 +4485,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SendAsyncFile ()
 		public void SendAsyncFile ()
 		{
 		{
 			Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 			Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
@@ -4352,6 +4546,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectToIPV4EndPointUsingDualModelSocket () {
 		public void ConnectToIPV4EndPointUsingDualModelSocket () {
 			/*
 			/*
 			 * IPv6 DualMode sockets are defaults in Mono. Explicitly specify that
 			 * IPv6 DualMode sockets are defaults in Mono. Explicitly specify that
@@ -4392,6 +4589,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginConnectToIPV4EndPointUsingDualModelSocket () {
 		public void BeginConnectToIPV4EndPointUsingDualModelSocket () {
 			/*
 			/*
 			 * IPv6 DualMode sockets are defaults in Mono. Explicitly specify that
 			 * IPv6 DualMode sockets are defaults in Mono. Explicitly specify that
@@ -4435,6 +4635,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UdpMulticasTimeToLive ()
 		public void UdpMulticasTimeToLive ()
 		{
 		{
 			/* see https://bugzilla.xamarin.com/show_bug.cgi?id=36941 */
 			/* see https://bugzilla.xamarin.com/show_bug.cgi?id=36941 */

+ 16 - 1
mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs

@@ -21,7 +21,6 @@ namespace MonoTests.System.Net.Sockets
 	/// Tests System.Net.Sockets.TcpClient
 	/// Tests System.Net.Sockets.TcpClient
 	/// </summary>
 	/// </summary>
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class TcpClientTest
 	public class TcpClientTest
 	{
 	{
 		
 		
@@ -30,6 +29,9 @@ namespace MonoTests.System.Net.Sockets
 		/// (from System.Net.Sockets)
 		/// (from System.Net.Sockets)
 		/// </summary>
 		/// </summary>
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TcpClient()
 		public void TcpClient()
 		{
 		{
 			// set up a listening Socket
 			// set up a listening Socket
@@ -77,6 +79,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test] // bug #81105
 		[Test] // bug #81105
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseTest ()
 		public void CloseTest ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -140,7 +145,11 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof(ArgumentNullException))]
 		[ExpectedException (typeof(ArgumentNullException))]
+#endif
 		public void ConnectMultiNull ()
 		public void ConnectMultiNull ()
 		{
 		{
 			TcpClient client = new TcpClient ();
 			TcpClient client = new TcpClient ();
@@ -150,6 +159,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectMultiAny ()
 		public void ConnectMultiAny ()
 		{
 		{
 			TcpClient client = new TcpClient ();
 			TcpClient client = new TcpClient ();
@@ -168,6 +180,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectMultiRefused ()
 		public void ConnectMultiRefused ()
 		{
 		{
 			TcpClient client = new TcpClient ();
 			TcpClient client = new TcpClient ();

+ 27 - 1
mcs/class/System/Test/System.Net.Sockets/TcpListenerTest.cs

@@ -20,10 +20,12 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net.Sockets
 namespace MonoTests.System.Net.Sockets
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class TcpListenerTest
 	public class TcpListenerTest
 	{
 	{
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TcpListener ()
 		public void TcpListener ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -75,6 +77,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CtorInt1 ()
 		public void CtorInt1 ()
 		{
 		{
 			int nex = 0;
 			int nex = 0;
@@ -87,21 +92,33 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentNullException))]
 		[ExpectedException (typeof (ArgumentNullException))]
+#endif
 		public void CtorIPEndPoint ()
 		public void CtorIPEndPoint ()
 		{
 		{
 			new TcpListener (null);
 			new TcpListener (null);
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentNullException))]
 		[ExpectedException (typeof (ArgumentNullException))]
+#endif
 		public void CtorIPAddressInt1 ()
 		public void CtorIPAddressInt1 ()
 		{
 		{
 			new TcpListener (null, 100000);
 			new TcpListener (null, 100000);
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
+#endif
 		public void CtorIPAddressInt2 ()
 		public void CtorIPAddressInt2 ()
 		{
 		{
 			new TcpListener (IPAddress.Any, 100000);
 			new TcpListener (IPAddress.Any, 100000);
@@ -125,6 +142,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PreStartStatus ()
 		public void PreStartStatus ()
 		{
 		{
 			MyListener listener = new MyListener ();
 			MyListener listener = new MyListener ();
@@ -152,6 +172,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PostStartStatus ()
 		public void PostStartStatus ()
 		{
 		{
 			MyListener listener = new MyListener ();
 			MyListener listener = new MyListener ();
@@ -173,6 +196,9 @@ namespace MonoTests.System.Net.Sockets
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void StartListenMoreThan5 ()
 		public void StartListenMoreThan5 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();

+ 121 - 1
mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs

@@ -15,9 +15,11 @@ using NUnit.Framework;
 
 
 namespace MonoTests.System.Net.Sockets {
 namespace MonoTests.System.Net.Sockets {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class UdpClientTest {
 	public class UdpClientTest {
 		[Test] // .ctor ()
 		[Test] // .ctor ()
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor1 ()
 		public void Constructor1 ()
 		{
 		{
 			MyUdpClient client;
 			MyUdpClient client;
@@ -43,6 +45,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (AddressFamily)
 		[Test] // .ctor (AddressFamily)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor2 ()
 		public void Constructor2 ()
 		{
 		{
 			MyUdpClient client;
 			MyUdpClient client;
@@ -88,6 +93,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (AddressFamily)
 		[Test] // .ctor (AddressFamily)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor2_Family_Invalid ()
 		public void Constructor2_Family_Invalid ()
 		{
 		{
 			try {
 			try {
@@ -114,6 +122,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (Int32)
 		[Test] // .ctor (Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor3 ()
 		public void Constructor3 ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -163,6 +174,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (Int32)
 		[Test] // .ctor (Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor3_Port_OutOfRange ()
 		public void Constructor3_Port_OutOfRange ()
 		{
 		{
 			try {
 			try {
@@ -189,6 +203,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (IPEndPoint)
 		[Test] // .ctor (IPEndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor4 ()
 		public void Constructor4 ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -221,6 +238,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (IPEndPoint)
 		[Test] // .ctor (IPEndPoint)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor4_LocalEP_Null ()
 		public void Constructor4_LocalEP_Null ()
 		{
 		{
 			try {
 			try {
@@ -235,6 +255,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (Int32, AddressFamily)
 		[Test] // .ctor (Int32, AddressFamily)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor5 ()
 		public void Constructor5 ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -288,6 +311,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (Int32, AddressFamily)
 		[Test] // .ctor (Int32, AddressFamily)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor5_Family_Invalid ()
 		public void Constructor5_Family_Invalid ()
 		{
 		{
 			try {
 			try {
@@ -318,6 +344,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (Int32, AddressFamily)
 		[Test] // .ctor (Int32, AddressFamily)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor5_Port_OutOfRange ()
 		public void Constructor5_Port_OutOfRange ()
 		{
 		{
 			try {
 			try {
@@ -344,6 +373,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (String, Int32)
 		[Test] // .ctor (String, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor6 ()
 		public void Constructor6 ()
 		{
 		{
 			Socket s;
 			Socket s;
@@ -394,6 +426,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (String, Int32)
 		[Test] // .ctor (String, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor6_HostName_Null ()
 		public void Constructor6_HostName_Null ()
 		{
 		{
 			try {
 			try {
@@ -408,6 +443,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // .ctor (String, Int32)
 		[Test] // .ctor (String, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Constructor6_Port_OutOfRange ()
 		public void Constructor6_Port_OutOfRange ()
 		{
 		{
 			try {
 			try {
@@ -434,6 +472,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UdpClientBroadcastTest () 
 		public void UdpClientBroadcastTest () 
 		{
 		{
 			UdpClient client = new UdpClient ();
 			UdpClient client = new UdpClient ();
@@ -447,6 +488,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup1_IPv4 ()
 		public void JoinMulticastGroup1_IPv4 ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -457,6 +501,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup1_IPv6 ()
 		public void JoinMulticastGroup1_IPv6 ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -470,6 +517,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup1_MulticastAddr_Null ()
 		public void JoinMulticastGroup1_MulticastAddr_Null ()
 		{
 		{
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -486,6 +536,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup1_Socket_Closed ()
 		public void JoinMulticastGroup1_Socket_Closed ()
 		{
 		{
 			IPAddress mcast_addr = null;
 			IPAddress mcast_addr = null;
@@ -528,6 +581,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (In32, IPAddress)
 		[Test] // JoinMulticastGroup (In32, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup2_IPv4 ()
 		public void JoinMulticastGroup2_IPv4 ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -550,6 +606,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (In32, IPAddress)
 		[Test] // JoinMulticastGroup (In32, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup2_IPv6 ()
 		public void JoinMulticastGroup2_IPv6 ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -563,6 +622,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (Int32, IPAddress)
 		[Test] // JoinMulticastGroup (Int32, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup2_MulticastAddr_Null ()
 		public void JoinMulticastGroup2_MulticastAddr_Null ()
 		{
 		{
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -579,6 +641,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (Int32, IPAddress)
 		[Test] // JoinMulticastGroup (Int32, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup2_Socket_Closed ()
 		public void JoinMulticastGroup2_Socket_Closed ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -624,6 +689,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup3_IPv4 ()
 		public void JoinMulticastGroup3_IPv4 ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -638,6 +706,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup3_IPv6 ()
 		public void JoinMulticastGroup3_IPv6 ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -655,6 +726,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup3_MulticastAddr_Null ()
 		public void JoinMulticastGroup3_MulticastAddr_Null ()
 		{
 		{
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -671,6 +745,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
 		[Test] // JoinMulticastGroup (IPAddress, Int32)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup3_Socket_Closed ()
 		public void JoinMulticastGroup3_Socket_Closed ()
 		{
 		{
 			IPAddress mcast_addr = null;
 			IPAddress mcast_addr = null;
@@ -713,6 +790,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup4_IPv4 ()
 		public void JoinMulticastGroup4_IPv4 ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -724,6 +804,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup4_IPv6 ()
 		public void JoinMulticastGroup4_IPv6 ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)
@@ -750,6 +833,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup4_LocalAddress_Null ()
 		public void JoinMulticastGroup4_LocalAddress_Null ()
 		{
 		{
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
 			IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -768,6 +854,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup4_MulticastAddr_Null ()
 		public void JoinMulticastGroup4_MulticastAddr_Null ()
 		{
 		{
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
 			using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -784,6 +873,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
 		[Test] // JoinMulticastGroup (IPAddress, IPAddress)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroup4_Socket_Closed ()
 		public void JoinMulticastGroup4_Socket_Closed ()
 		{
 		{
 			IPAddress mcast_addr = null;
 			IPAddress mcast_addr = null;
@@ -828,6 +920,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseInReceive ()
 		public void CloseInReceive ()
 		{
 		{
 			UdpClient client = null;
 			UdpClient client = null;
@@ -868,6 +963,9 @@ namespace MonoTests.System.Net.Sockets {
 
 
 		// Test for bug 324033
 		// Test for bug 324033
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void JoinMulticastGroupWithLocal ()
 		public void JoinMulticastGroupWithLocal ()
 		{
 		{
 			UdpClient client = new UdpClient (9001);
 			UdpClient client = new UdpClient (9001);
@@ -882,7 +980,11 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof(ArgumentNullException))]
 		[ExpectedException (typeof(ArgumentNullException))]
+#endif
 		public void BeginSendNull ()
 		public void BeginSendNull ()
 		{
 		{
 			UdpClient client = new UdpClient ();
 			UdpClient client = new UdpClient ();
@@ -905,6 +1007,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginSend ()
 		public void BeginSend ()
 		{
 		{
 			UdpClient client = new UdpClient ();
 			UdpClient client = new UdpClient ();
@@ -959,6 +1064,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginReceive ()
 		public void BeginReceive ()
 		{
 		{
 			UdpClient client = new UdpClient (1237);
 			UdpClient client = new UdpClient (1237);
@@ -984,6 +1092,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Available ()
 		public void Available ()
 		{
 		{
 			using (UdpClient client = new UdpClient (1238)) {
 			using (UdpClient client = new UdpClient (1238)) {
@@ -1018,6 +1129,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void EnableBroadcastDefault ()
 		public void EnableBroadcastDefault ()
 		{
 		{
 			UdpClient client = new UdpClient ();
 			UdpClient client = new UdpClient ();
@@ -1057,6 +1171,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void MulticastLoopbackDefault ()
 		public void MulticastLoopbackDefault ()
 		{
 		{
 			UdpClient client = new UdpClient ();
 			UdpClient client = new UdpClient ();
@@ -1067,6 +1184,9 @@ namespace MonoTests.System.Net.Sockets {
 		}
 		}
 
 
 		[Test] // #6057
 		[Test] // #6057
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveIPv6 ()
 		public void ReceiveIPv6 ()
 		{
 		{
 			if (!Socket.OSSupportsIPv6)
 			if (!Socket.OSSupportsIPv6)

+ 21 - 19
mcs/class/System/Test/System.Net.WebSockets/ClientWebSocketTest.cs

@@ -18,31 +18,33 @@ namespace MonoTests.System.Net.WebSockets
 	{
 	{
 		const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
 		const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
 		int Port = NetworkHelpers.FindFreePort ();
 		int Port = NetworkHelpers.FindFreePort ();
-		HttpListener listener;
-		ClientWebSocket socket;
-		MethodInfo headerSetMethod;
-
-		[SetUp]
-		public void Setup ()
-		{
-			listener = new HttpListener ();
-			listener.Prefixes.Add ("http://localhost:" + Port + "/");
-			listener.Start ();
-			socket = new ClientWebSocket ();
+		HttpListener _listener;
+		HttpListener listener {
+			get {
+				if (_listener != null)
+					return _listener;
+				var tmp = new HttpListener ();
+				tmp.Prefixes.Add ("http://localhost:" + Port + "/");
+				tmp.Start ();
+				return _listener = tmp;
+			}
 		}
 		}
+		ClientWebSocket _socket;
+		ClientWebSocket socket { get { return _socket ?? (_socket = new ClientWebSocket ()); } }
+		MethodInfo headerSetMethod;
 
 
 		[TearDown]
 		[TearDown]
 		public void Teardown ()
 		public void Teardown ()
 		{
 		{
-			if (listener != null) {
-				listener.Stop ();
-				listener = null;
+			if (_listener != null) {
+				_listener.Stop ();
+				_listener = null;
 			}
 			}
-			if (socket != null) {
-				if (socket.State == WebSocketState.Open)
-					socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
-				socket.Dispose ();
-				socket = null;
+			if (_socket != null) {
+				if (_socket.State == WebSocketState.Open)
+					_socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
+				_socket.Dispose ();
+				_socket = null;
 			}
 			}
 		}
 		}
 
 

+ 40 - 5
mcs/class/System/Test/System.Net/CookieParserTest.cs

@@ -9,7 +9,6 @@ using NUnit.Framework;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class CookieParserTest
 	public class CookieParserTest
 	{
 	{
 		public const string A = "Foo=Bar, expires=World; expires=Sat, 11-Oct-14 22:45:19 GMT, A=B";
 		public const string A = "Foo=Bar, expires=World; expires=Sat, 11-Oct-14 22:45:19 GMT, A=B";
@@ -72,6 +71,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestExpires ()
 		public void TestExpires ()
 		{
 		{
 			var cookies = DoRequest (A);
 			var cookies = DoRequest (A);
@@ -82,6 +84,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestInvalidCookie ()
 		public void TestInvalidCookie ()
 		{
 		{
 			var cookies = DoRequest (B);
 			var cookies = DoRequest (B);
@@ -92,6 +97,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestLocalCulture ()
 		public void TestLocalCulture ()
 		{
 		{
 			var old = Thread.CurrentThread.CurrentCulture;
 			var old = Thread.CurrentThread.CurrentCulture;
@@ -109,6 +117,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestMultiple ()
 		public void TestMultiple ()
 		{
 		{
 			var cookies = DoRequest (D);
 			var cookies = DoRequest (D);
@@ -119,6 +130,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestMultiple2 ()
 		public void TestMultiple2 ()
 		{
 		{
 			var cookies = DoRequest (E);
 			var cookies = DoRequest (E);
@@ -128,6 +142,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestQuotation ()
 		public void TestQuotation ()
 		{
 		{
 			var cookies = DoRequest (F);
 			var cookies = DoRequest (F);
@@ -140,6 +157,7 @@ namespace MonoTests.System.Net
 		{
 		{
 			Socket socket;
 			Socket socket;
 			string[] headers;
 			string[] headers;
+			Exception ex;
 
 
 			public Listener (params string[] headers)
 			public Listener (params string[] headers)
 			{
 			{
@@ -155,17 +173,28 @@ namespace MonoTests.System.Net
 				socket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
 				socket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
 				socket.Listen (1);
 				socket.Listen (1);
 				socket.BeginAccept ((result) => {
 				socket.BeginAccept ((result) => {
-					var accepted = socket.EndAccept (result);
-					HandleRequest (accepted);
+					try {
+						var accepted = socket.EndAccept (result);
+						HandleRequest (accepted);
+					} catch (Exception e) {
+						ex = e;
+					}
 				}, null);
 				}, null);
 			}
 			}
 
 
+			void ThrowIfException ()
+			{
+				if (ex != null)
+					throw ex;
+			}
+
 			public void Dispose ()
 			public void Dispose ()
 			{
 			{
 				if (socket != null) {
 				if (socket != null) {
 					socket.Close ();
 					socket.Close ();
 					socket = null;
 					socket = null;
 				}
 				}
+				ThrowIfException ();
 			}
 			}
 
 
 			void HandleRequest (Socket accepted)
 			void HandleRequest (Socket accepted)
@@ -183,11 +212,17 @@ namespace MonoTests.System.Net
 			}
 			}
 
 
 			public EndPoint EndPoint {
 			public EndPoint EndPoint {
-				get { return socket.LocalEndPoint; }
+				get {
+					ThrowIfException ();
+					return socket.LocalEndPoint;
+				}
 			}
 			}
 
 
 			public string URI {
 			public string URI {
-				get { return string.Format ("http://{0}/", EndPoint); }
+				get {
+					ThrowIfException ();
+					return string.Format ("http://{0}/", EndPoint);
+				}
 			}
 			}
 		}
 		}
 	}
 	}

+ 36 - 1
mcs/class/System/Test/System.Net/DnsTest.cs

@@ -19,7 +19,6 @@ using NUnit.Framework;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class DnsTest
 	public class DnsTest
 	{
 	{
 		private String site1Name = "google-public-dns-a.google.com",
 		private String site1Name = "google-public-dns-a.google.com",
@@ -30,6 +29,9 @@ namespace MonoTests.System.Net
 		private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
 		private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AsyncGetHostByName ()
 		public void AsyncGetHostByName ()
 		{
 		{
 			IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
 			IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
@@ -39,6 +41,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AsyncGetHostByNameCallback ()
 		public void AsyncGetHostByNameCallback ()
 		{
 		{
 			var evt = new ManualResetEvent (false);
 			var evt = new ManualResetEvent (false);
@@ -61,6 +66,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AsyncResolve ()
 		public void AsyncResolve ()
 		{
 		{
 			IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);
 			IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);
@@ -71,6 +79,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AsyncResolveCallback ()
 		public void AsyncResolveCallback ()
 		{
 		{
 			var evt = new ManualResetEvent (false);
 			var evt = new ManualResetEvent (false);
@@ -205,6 +216,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetHostByName ()
 		public void GetHostByName ()
 		{
 		{
 			SubTestGetHostByName (site1Name, site1Dot);
 			SubTestGetHostByName (site1Name, site1Dot);
@@ -336,6 +350,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginResolve_HostName_Null ()
 		public void BeginResolve_HostName_Null ()
 		{
 		{
 			try {
 			try {
@@ -352,6 +369,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Resolve ()
 		public void Resolve ()
 		{
 		{
 			SubTestResolve (site1Name);
 			SubTestResolve (site1Name);
@@ -367,6 +387,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Resolve_HostName_Null ()
 		public void Resolve_HostName_Null ()
 		{
 		{
 			try {
 			try {
@@ -381,6 +404,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)
 		[Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetHostEntry1_Address_Null ()
 		public void BeginGetHostEntry1_Address_Null ()
 		{
 		{
 			try {
 			try {
@@ -398,6 +424,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
 		[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetHostEntry2_HostNameOrAddress_Null ()
 		public void BeginGetHostEntry2_HostNameOrAddress_Null ()
 		{
 		{
 			try {
 			try {
@@ -415,6 +444,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
 		[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()
 		public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()
 		{
 		{
 			// IPv4
 			// IPv4
@@ -473,6 +505,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // GetHostEntry (String)
 		[Test] // GetHostEntry (String)
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetHostEntry2 ()
 		public void GetHostEntry2 ()
 		{
 		{
 			Dns.GetHostEntry (site1Name); // hostname
 			Dns.GetHostEntry (site1Name); // hostname

+ 0 - 1
mcs/class/System/Test/System.Net/FileWebRequestTest.cs

@@ -25,7 +25,6 @@ using NUnit.Framework;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class FileWebRequestTest
 	public class FileWebRequestTest
 	{
 	{
 		private string _tempDirectory;
 		private string _tempDirectory;

+ 55 - 8
mcs/class/System/Test/System.Net/FtpWebRequestTest.cs

@@ -19,10 +19,12 @@ using System.Threading;
 namespace MonoTests.System.Net 
 namespace MonoTests.System.Net 
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class FtpWebRequestTest
 	public class FtpWebRequestTest
 	{
 	{
-		FtpWebRequest defaultRequest;
+		FtpWebRequest _defaultRequest;
+		FtpWebRequest defaultRequest {
+			get { return _defaultRequest ?? (_defaultRequest = (FtpWebRequest) WebRequest.Create ("ftp://www.contoso.com")); }
+		}
 		
 		
 		private string _tempDirectory;
 		private string _tempDirectory;
 		private string _tempFile;
 		private string _tempFile;
@@ -49,25 +51,31 @@ namespace MonoTests.System.Net
 				Directory.Delete (_tempDirectory, true);
 				Directory.Delete (_tempDirectory, true);
 		}
 		}
 
 
-		[TestFixtureSetUp]
-		public void Init ()
-		{
-			defaultRequest = (FtpWebRequest) WebRequest.Create ("ftp://www.contoso.com");
-		}
-		
 		[Test]
 		[Test]
 		public void ContentLength ()
 		public void ContentLength ()
 		{
 		{
 			try {
 			try {
 				long l = defaultRequest.ContentLength;
 				long l = defaultRequest.ContentLength;
+#if FEATURE_NO_BSD_SOCKETS
+				Assert.Fail ("#1a");
+			} catch (PlatformNotSupportedException) {
+				// OK.
+#else
 			} catch (NotSupportedException) {
 			} catch (NotSupportedException) {
 				Assert.Fail ("#1"); // Not overriden
 				Assert.Fail ("#1"); // Not overriden
+#endif
 			}
 			}
 
 
 			try {
 			try {
 				defaultRequest.ContentLength = 2;
 				defaultRequest.ContentLength = 2;
+#if FEATURE_NO_BSD_SOCKETS
+				Assert.Fail ("#2a");
+			} catch (PlatformNotSupportedException) {
+				// OK.
+#else
 			} catch (NotSupportedException) {
 			} catch (NotSupportedException) {
 				Assert.Fail ("#2"); // Not overriden
 				Assert.Fail ("#2"); // Not overriden
+#endif
 			}
 			}
 		}
 		}
 
 
@@ -88,6 +96,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ContentOffset ()
 		public void ContentOffset ()
 		{
 		{
 			try {
 			try {
@@ -98,6 +109,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Credentials ()
 		public void Credentials ()
 		{
 		{
 			try {
 			try {
@@ -109,6 +123,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Method ()
 		public void Method ()
 		{
 		{
 			try {
 			try {
@@ -146,6 +163,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadWriteTimeout ()
 		public void ReadWriteTimeout ()
 		{
 		{
 			try {
 			try {
@@ -156,6 +176,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Timeout ()
 		public void Timeout ()
 		{
 		{
 			try {
 			try {
@@ -166,6 +189,9 @@ namespace MonoTests.System.Net
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DefaultValues ()
 		public void DefaultValues ()
 		{
 		{
 			FtpWebRequest request = (FtpWebRequest) WebRequest.Create ("ftp://www.contoso.com");
 			FtpWebRequest request = (FtpWebRequest) WebRequest.Create ("ftp://www.contoso.com");
@@ -183,6 +209,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void RenameTo ()
 		public void RenameTo ()
 		{
 		{
 			try {
 			try {
@@ -199,6 +228,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadFile1 ()
 		public void UploadFile1 ()
 		{
 		{
 			ServerPut sp = new ServerPut ();
 			ServerPut sp = new ServerPut ();
@@ -229,6 +261,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadFile_WebClient ()
 		public void UploadFile_WebClient ()
 		{
 		{
 			ServerPut sp = new ServerPut ();
 			ServerPut sp = new ServerPut ();
@@ -247,6 +282,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DownloadFile1 ()
 		public void DownloadFile1 ()
 		{
 		{
 			DownloadFile (new ServerDownload ());
 			DownloadFile (new ServerDownload ());
@@ -279,6 +317,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DownloadFile2 ()
 		public void DownloadFile2 ()
 		{
 		{
 			// Some embedded FTP servers in Industrial Automation Hardware report
 			// Some embedded FTP servers in Industrial Automation Hardware report
@@ -287,6 +328,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DeleteFile1 ()
 		public void DeleteFile1 ()
 		{
 		{
 			ServerDeleteFile sp = new ServerDeleteFile ();
 			ServerDeleteFile sp = new ServerDeleteFile ();
@@ -313,6 +357,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ListDirectory1 ()
 		public void ListDirectory1 ()
 		{
 		{
 			ServerListDirectory sp = new ServerListDirectory ();
 			ServerListDirectory sp = new ServerListDirectory ();

+ 84 - 2
mcs/class/System/Test/System.Net/HttpListener2Test.cs

@@ -47,7 +47,6 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net {
 namespace MonoTests.System.Net {
 	
 	
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpListener2Test {
 	public class HttpListener2Test {
 		
 		
 		private HttpListener _listener = null;
 		private HttpListener _listener = null;
@@ -147,6 +146,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test1 ()
 		public void Test1 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -159,6 +161,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test2 ()
 		public void Test2 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -171,6 +176,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test3 ()
 		public void Test3 ()
 		{
 		{
 			StringBuilder bad = new StringBuilder ();
 			StringBuilder bad = new StringBuilder ();
@@ -210,6 +218,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test4 ()
 		public void Test4 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -222,6 +233,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test5 ()
 		public void Test5 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -234,6 +248,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test6 ()
 		public void Test6 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -247,6 +264,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test7 ()
 		public void Test7 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -263,6 +283,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test8 ()
 		public void Test8 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -280,6 +303,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test9 ()
 		public void Test9 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -295,6 +321,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test10 ()
 		public void Test10 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -311,6 +340,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test11 ()
 		public void Test11 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -325,6 +357,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test12 ()
 		public void Test12 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -339,6 +374,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test13 ()
 		public void Test13 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -356,6 +394,9 @@ namespace MonoTests.System.Net {
 		ManualResetEvent test_evt;
 		ManualResetEvent test_evt;
 		bool test14_error;
 		bool test14_error;
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test14 ()
 		public void Test14 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -392,6 +433,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test15 ()
 		public void Test15 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -414,6 +458,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test16 ()
 		public void Test16 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -438,6 +485,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test17 ()
 		public void Test17 ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -454,6 +504,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test_MultipleClosesOnOuputStreamAllowed ()
 		public void Test_MultipleClosesOnOuputStreamAllowed ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -484,6 +537,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReceiveCookiesFromClient ()
 		public void ReceiveCookiesFromClient ()
 		{
 		{
 			sendCookiePort = NetworkHelpers.FindFreePort ();			
 			sendCookiePort = NetworkHelpers.FindFreePort ();			
@@ -530,6 +586,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void SendCookiestoClient ()
 		public void SendCookiestoClient ()
 		{
 		{
 			receiveCookiePort = NetworkHelpers.FindFreePort ();
 			receiveCookiePort = NetworkHelpers.FindFreePort ();
@@ -581,6 +640,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void MultiResponses ()
 		public void MultiResponses ()
 		{
 		{
 			echoServerPort = NetworkHelpers.FindFreePort ();
 			echoServerPort = NetworkHelpers.FindFreePort ();
@@ -646,9 +708,11 @@ namespace MonoTests.System.Net {
 	}
 	}
 
 
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpListenerBugs {
 	public class HttpListenerBugs {
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestNonChunkedAsync ()
 		public void TestNonChunkedAsync ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -703,6 +767,9 @@ namespace MonoTests.System.Net {
 		// a documented pattern to close the connection
 		// a documented pattern to close the connection
 		// 
 		// 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test_MultipleConnections ()
 		public void Test_MultipleConnections ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();			
 			var port = NetworkHelpers.FindFreePort ();			
@@ -733,6 +800,9 @@ namespace MonoTests.System.Net {
 		// Test case for bug 341443, an pretty old bug, filed on November of 2007.
 		// Test case for bug 341443, an pretty old bug, filed on November of 2007.
 		//
 		//
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test_HostInUri ()
 		public void Test_HostInUri ()
 		{
 		{
 			var wait = new ManualResetEvent (false);
 			var wait = new ManualResetEvent (false);
@@ -762,6 +832,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test] // bug #513849
 		[Test] // bug #513849
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ClosePort ()
 		public void ClosePort ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -785,6 +858,9 @@ namespace MonoTests.System.Net {
 		// does not also listen to another interface.
 		// does not also listen to another interface.
 		//
 		//
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BindToSingleInterface ()
 		public void BindToSingleInterface ()
 		{
 		{
 			IPAddress [] machineAddress = null;
 			IPAddress [] machineAddress = null;
@@ -811,6 +887,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BindToAllInterfaces ()
 		public void BindToAllInterfaces ()
 		{
 		{
 			var h = new HttpListener ();
 			var h = new HttpListener ();
@@ -823,6 +902,9 @@ namespace MonoTests.System.Net {
 
 
 		// Test case for bug #31209
 		// Test case for bug #31209
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Test_EmptyLineAtStart ()
 		public void Test_EmptyLineAtStart ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();

+ 66 - 2
mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs

@@ -36,6 +36,9 @@ namespace MonoTests.System.Net {
 	public class HttpListenerPrefixCollectionTest {
 	public class HttpListenerPrefixCollectionTest {
 		// NL -> Not listening -> tests when listener.IsListening == false
 		// NL -> Not listening -> tests when listener.IsListening == false
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NL_DefaultProperties ()
 		public void NL_DefaultProperties ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -46,6 +49,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DefaultProperties ()
 		public void DefaultProperties ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -57,7 +63,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AddOne ()
 		public void AddOne ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -71,7 +79,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Duplicate ()
 		public void Duplicate ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -86,6 +96,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void EndsWithSlash ()
 		public void EndsWithSlash ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -93,6 +106,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DifferentPath ()
 		public void DifferentPath ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -102,6 +118,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NL_Clear ()
 		public void NL_Clear ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -110,6 +129,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NL_Remove ()
 		public void NL_Remove ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -118,6 +140,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NL_RemoveBadUri ()
 		public void NL_RemoveBadUri ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -126,7 +151,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void NL_AddBadUri ()
 		public void NL_AddBadUri ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -135,7 +164,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void NoHostInUrl ()
 		public void NoHostInUrl ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -143,6 +176,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void MultipleSlashes ()
 		public void MultipleSlashes ()
 		{
 		{
 			// this one throws on Start(), not when adding it.
 			// this one throws on Start(), not when adding it.
@@ -156,6 +192,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PercentSign ()
 		public void PercentSign ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -169,6 +208,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Disposed1 ()
 		public void Disposed1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -180,7 +222,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed2 ()
 		public void Disposed2 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -190,7 +236,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed3 ()
 		public void Disposed3 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -200,7 +250,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed4 ()
 		public void Disposed4 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -210,7 +264,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void Disposed5 ()
 		public void Disposed5 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -221,6 +279,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Disposed6 ()
 		public void Disposed6 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -234,6 +295,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Disposed7 ()
 		public void Disposed7 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();

+ 15 - 1
mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs

@@ -42,7 +42,6 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpListenerRequestTest
 	public class HttpListenerRequestTest
 	{
 	{
 		[Test]
 		[Test]
@@ -151,6 +150,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpMethod ()
 		public void HttpMethod ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -165,6 +167,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpBasicAuthScheme ()
 		public void HttpBasicAuthScheme ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();			
 			var port = NetworkHelpers.FindFreePort ();			
@@ -180,6 +185,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpRequestUriIsNotDecoded ()
 		public void HttpRequestUriIsNotDecoded ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -194,6 +202,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpRequestIsLocal ()
 		public void HttpRequestIsLocal ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();
@@ -221,6 +232,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // #29927
 		[Test] // #29927
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpRequestUriUnescape ()
 		public void HttpRequestUriUnescape ()
 		{
 		{
 			var prefix = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
 			var prefix = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";

+ 119 - 6
mcs/class/System/Test/System.Net/HttpListenerTest.cs

@@ -37,17 +37,17 @@ using MonoTests.Helpers;
 
 
 namespace MonoTests.System.Net {
 namespace MonoTests.System.Net {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpListenerTest {
 	public class HttpListenerTest {
 
 
-		int port;
-
-		[SetUp]
-		public void SetUp () {
-			port = NetworkHelpers.FindFreePort ();
+		int? _port;
+		int port {
+			get { return _port ?? (_port = NetworkHelpers.FindFreePort ()).Value; }
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DefaultProperties ()
 		public void DefaultProperties ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -61,6 +61,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Start1 ()
 		public void Start1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -68,6 +71,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Stop1 ()
 		public void Stop1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -75,7 +81,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (InvalidOperationException))]
 		[ExpectedException (typeof (InvalidOperationException))]
+#endif
 		public void GetContext1 ()
 		public void GetContext1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -84,7 +94,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (InvalidOperationException))]
 		[ExpectedException (typeof (InvalidOperationException))]
+#endif
 		public void GetContext2 ()
 		public void GetContext2 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -94,7 +108,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (InvalidOperationException))]
 		[ExpectedException (typeof (InvalidOperationException))]
+#endif
 		public void BeginGetContext1 ()
 		public void BeginGetContext1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -103,6 +121,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetContext2 ()
 		public void BeginGetContext2 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -135,6 +156,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DefaultHttpPort ()
 		public void DefaultHttpPort ()
 		{
 		{
 			if (!CanOpenPort (80))
 			if (!CanOpenPort (80))
@@ -148,6 +172,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void DefaultHttpsPort ()
 		public void DefaultHttpsPort ()
 		{
 		{
 			if (!CanOpenPort (443))
 			if (!CanOpenPort (443))
@@ -161,6 +188,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TwoListeners_SameAddress ()
 		public void TwoListeners_SameAddress ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -174,7 +204,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (HttpListenerException))]
 		[ExpectedException (typeof (HttpListenerException))]
+#endif
 		public void TwoListeners_SameURL ()
 		public void TwoListeners_SameURL ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -188,7 +222,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (HttpListenerException))]
 		[ExpectedException (typeof (HttpListenerException))]
+#endif
 		public void MultipleSlashes ()
 		public void MultipleSlashes ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -200,7 +238,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (HttpListenerException))]
 		[ExpectedException (typeof (HttpListenerException))]
+#endif
 		public void PercentSign ()
 		public void PercentSign ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -212,6 +254,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseBeforeStart ()
 		public void CloseBeforeStart ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -219,6 +264,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseTwice ()
 		public void CloseTwice ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -231,6 +279,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void StartStopStart ()
 		public void StartStopStart ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -244,6 +295,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void StartStopDispose ()
 		public void StartStopDispose ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -256,6 +310,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AbortBeforeStart ()
 		public void AbortBeforeStart ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -263,6 +320,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AbortTwice ()
 		public void AbortTwice ()
 		{
 		{
 			if (!CanOpenPort (port))
 			if (!CanOpenPort (port))
@@ -275,6 +335,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PropertiesWhenClosed1 ()
 		public void PropertiesWhenClosed1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -288,7 +351,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosed2 ()
 		public void PropertiesWhenClosed2 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -297,7 +364,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosedSet1 ()
 		public void PropertiesWhenClosedSet1 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -306,7 +377,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosedSet2 ()
 		public void PropertiesWhenClosedSet2 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -315,7 +390,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosedSet3 ()
 		public void PropertiesWhenClosedSet3 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -324,7 +403,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosedSet4 ()
 		public void PropertiesWhenClosedSet4 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -333,7 +416,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ObjectDisposedException))]
 		[ExpectedException (typeof (ObjectDisposedException))]
+#endif
 		public void PropertiesWhenClosedSet5 ()
 		public void PropertiesWhenClosedSet5 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -342,6 +429,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PropertiesWhenClosed3 ()
 		public void PropertiesWhenClosed3 ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -350,6 +440,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseWhileBegin ()
 		public void CloseWhileBegin ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -366,6 +459,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AbortWhileBegin ()
 		public void AbortWhileBegin ()
 		{
 		{
 			HttpListener listener = new HttpListener ();
 			HttpListener listener = new HttpListener ();
@@ -382,7 +478,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (HttpListenerException))]
 		[ExpectedException (typeof (HttpListenerException))]
+#endif
 		public void CloseWhileGet ()
 		public void CloseWhileGet ()
 		{
 		{
 			// "System.Net.HttpListener Exception : The I/O operation has been aborted
 			// "System.Net.HttpListener Exception : The I/O operation has been aborted
@@ -399,7 +499,11 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (HttpListenerException))]
 		[ExpectedException (typeof (HttpListenerException))]
+#endif
 		public void AbortWhileGet ()
 		public void AbortWhileGet ()
 		{
 		{
 			// "System.Net.HttpListener Exception : The I/O operation has been aborted
 			// "System.Net.HttpListener Exception : The I/O operation has been aborted
@@ -479,6 +583,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ConnectionReuse ()
 		public void ConnectionReuse ()
 		{
 		{
 			var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
 			var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
@@ -536,6 +643,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UserHeaderWithDoubleMultiValue ()
 		public void UserHeaderWithDoubleMultiValue ()
 		{
 		{
 			string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
 			string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
@@ -563,6 +673,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HttpClientIsDisconnectedCheckForWriteException()
 		public void HttpClientIsDisconnectedCheckForWriteException()
 		{
 		{
 			string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
 			string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";

+ 222 - 6
mcs/class/System/Test/System.Net/HttpWebRequestTest.cs

@@ -36,7 +36,6 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpWebRequestTest
 	public class HttpWebRequestTest
 	{
 	{
 		private Random rand = new Random ();
 		private Random rand = new Random ();
@@ -45,11 +44,16 @@ namespace MonoTests.System.Net
 		[TestFixtureSetUp]
 		[TestFixtureSetUp]
 		public void Setup ()
 		public void Setup ()
 		{
 		{
+#if !FEATURE_NO_BSD_SOCKETS
 				ServicePointManager.Expect100Continue = false;
 				ServicePointManager.Expect100Continue = false;
+#endif
 				rand.NextBytes (data64KB);
 				rand.NextBytes (data64KB);
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Proxy_Null ()
 		public void Proxy_Null ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
@@ -60,6 +64,9 @@ namespace MonoTests.System.Net
 
 
 		[Test]
 		[Test]
 		[Category("InetAccess")]
 		[Category("InetAccess")]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Sync ()
 		public void Sync ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
@@ -81,6 +88,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AddRange ()
 		public void AddRange ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
@@ -96,6 +106,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #471782
 		[Test] // bug #471782
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CloseRequestStreamAfterReadingResponse ()
 		public void CloseRequestStreamAfterReadingResponse ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -182,6 +195,9 @@ namespace MonoTests.System.Net
 		}
 		}
 #endif
 #endif
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Missing_ContentEncoding ()
 		public void Missing_ContentEncoding ()
 		{
 		{
 			ServicePointManager.CertificatePolicy = new AcceptAllPolicy ();
 			ServicePointManager.CertificatePolicy = new AcceptAllPolicy ();
@@ -204,6 +220,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BadServer_ChunkedClose ()
 		public void BadServer_ChunkedClose ()
 		{
 		{
 			// The server will send a chunked response without a 'last-chunked' mark
 			// The server will send a chunked response without a 'last-chunked' mark
@@ -269,6 +288,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStream_Body_NotAllowed ()
 		public void BeginGetRequestStream_Body_NotAllowed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -306,6 +328,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #465613
 		[Test] // bug #465613
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStream_NoBuffering ()
 		public void BeginGetRequestStream_NoBuffering ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -455,6 +480,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #511851
 		[Test] // bug #511851
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStream_Request_Aborted ()
 		public void BeginGetRequestStream_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -480,6 +508,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #511851
 		[Test] // bug #511851
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetResponse_Request_Aborted ()
 		public void BeginGetResponse_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -505,6 +536,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void EndGetRequestStream_AsyncResult_Null ()
 		public void EndGetRequestStream_AsyncResult_Null ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -583,6 +617,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void EndGetResponse_AsyncResult_Null ()
 		public void EndGetResponse_AsyncResult_Null ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -614,6 +651,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #429200
 		[Test] // bug #429200
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetRequestStream ()
 		public void GetRequestStream ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -636,6 +676,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #511851
 		[Test] // bug #511851
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetRequestStream_Request_Aborted ()
 		public void GetRequestStream_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -931,6 +974,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #511851
 		[Test] // bug #511851
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetResponse_Request_Aborted ()
 		public void GetResponse_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -987,6 +1033,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #324300
 		[Test] // bug #324300
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AllowAutoRedirect ()
 		public void AllowAutoRedirect ()
 		{
 		{
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1033,6 +1082,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PostAndRedirect_NoCL ()
 		public void PostAndRedirect_NoCL ()
 		{
 		{
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1061,6 +1113,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PostAndRedirect_CL ()
 		public void PostAndRedirect_CL ()
 		{
 		{
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1089,6 +1144,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PostAnd401 ()
 		public void PostAnd401 ()
 		{
 		{
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint localEP = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1250,6 +1308,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #513087
 		[Test] // bug #513087
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NonStandardVerb ()
 		public void NonStandardVerb ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1361,11 +1422,11 @@ namespace MonoTests.System.Net
 
 
 			internal void LaunchWebRequest ()
 			internal void LaunchWebRequest ()
 			{
 			{
-				var req = (HttpWebRequest) WebRequest.Create (url_to_test);
-				req.Timeout = TimeOutInMilliSeconds;
-
-				Start = DateTime.Now;
 				try {
 				try {
+					var req = (HttpWebRequest) WebRequest.Create (url_to_test);
+					req.Timeout = TimeOutInMilliSeconds;
+
+					Start = DateTime.Now;
 					using (var resp = (HttpWebResponse) req.GetResponse ())
 					using (var resp = (HttpWebResponse) req.GetResponse ())
 					{
 					{
 						var sr = new StreamReader (resp.GetResponseStream (), Encoding.UTF8);
 						var sr = new StreamReader (resp.GetResponseStream (), Encoding.UTF8);
@@ -1416,6 +1477,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // 1st possible case of https://bugzilla.novell.com/show_bug.cgi?id=MONO74177
 		[Test] // 1st possible case of https://bugzilla.novell.com/show_bug.cgi?id=MONO74177
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestTimeoutPropertyWithServerThatExistsAndRespondsButTooLate ()
 		public void TestTimeoutPropertyWithServerThatExistsAndRespondsButTooLate ()
 		{
 		{
 			var ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			var ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1428,6 +1492,7 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // 2nd possible case of https://bugzilla.novell.com/show_bug.cgi?id=MONO74177
 		[Test] // 2nd possible case of https://bugzilla.novell.com/show_bug.cgi?id=MONO74177
+		[Category ("RequiresBSDSockets")] // Requires some test refactoring to assert that a PlatformNotSupportedException is thrown, so don't bother (there's plenty of other tests asserting the PlatformNotSupported exceptions).
 		public void TestTimeoutWithEndpointThatDoesntExistThrowsConnectFailureBeforeTimeout ()
 		public void TestTimeoutWithEndpointThatDoesntExistThrowsConnectFailureBeforeTimeout ()
 		{
 		{
 			string url = "http://127.0.0.1:8271/"; // some endpoint that is unlikely to exist
 			string url = "http://127.0.0.1:8271/"; // some endpoint that is unlikely to exist
@@ -1682,6 +1747,9 @@ namespace MonoTests.System.Net
 			return Encoding.UTF8.GetBytes (sw.ToString ());
 			return Encoding.UTF8.GetBytes (sw.ToString ());
 		}
 		}
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NtlmAuthentication ()
 		public void NtlmAuthentication ()
 		{
 		{
 			NtlmServer server = new NtlmServer ();
 			NtlmServer server = new NtlmServer ();
@@ -1824,6 +1892,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStream ()
 		public void BeginGetRequestStream ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1842,6 +1913,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStreamNoClose ()
 		public void BeginGetRequestStreamNoClose ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1859,6 +1933,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetRequestStreamCancelIfNotAllBytesWritten ()
 		public void BeginGetRequestStreamCancelIfNotAllBytesWritten ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1883,6 +1960,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetRequestStream2 ()
 		public void GetRequestStream2 ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1899,6 +1979,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetRequestStreamNotAllBytesWritten ()
 		public void GetRequestStreamNotAllBytesWritten ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1914,6 +1997,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetRequestStreamTimeout ()
 		public void GetRequestStreamTimeout ()
 		{
 		{
 			this.DoRequest (
 			this.DoRequest (
@@ -1929,6 +2015,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginWrite ()
 		public void BeginWrite ()
 		{
 		{
 			byte[] received = new byte[data64KB.Length];
 			byte[] received = new byte[data64KB.Length];
@@ -1961,6 +2050,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginWriteAfterAbort ()
 		public void BeginWriteAfterAbort ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -1988,6 +2080,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PrematureStreamCloseAborts ()
 		public void PrematureStreamCloseAborts ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2015,6 +2110,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write ()
 		public void Write ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2086,6 +2184,9 @@ namespace MonoTests.System.Net
 		**/
 		**/
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read ()
 		public void Read ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2113,6 +2214,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadTimeout2 ()
 		public void ReadTimeout2 ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2142,6 +2246,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadServerAborted ()
 		public void ReadServerAborted ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2166,6 +2273,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetResponse2 ()
 		public void BeginGetResponse2 ()
 		{
 		{
 			byte [] received = new byte [data64KB.Length];
 			byte [] received = new byte [data64KB.Length];
@@ -2196,6 +2306,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginGetResponseAborts ()
 		public void BeginGetResponseAborts ()
 		{
 		{
 			ManualResetEvent aborted = new ManualResetEvent(false);
 			ManualResetEvent aborted = new ManualResetEvent(false);
@@ -2226,6 +2339,9 @@ namespace MonoTests.System.Net
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void TestLargeDataReading ()
 		public void TestLargeDataReading ()
 		{
 		{
 			int near2GBStartPosition = rand.Next (int.MaxValue - 500, int.MaxValue);
 			int near2GBStartPosition = rand.Next (int.MaxValue - 500, int.MaxValue);
@@ -2323,7 +2439,11 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentNullException))]
 		[ExpectedException (typeof (ArgumentNullException))]
+#endif
 		public void NullHost ()
 		public void NullHost ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2331,6 +2451,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NoHost ()
 		public void NoHost ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2338,7 +2461,11 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void EmptyHost ()
 		public void EmptyHost ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2346,6 +2473,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void HostAndPort ()
 		public void HostAndPort ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com:80");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com:80");
@@ -2355,6 +2485,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void PortRange ()
 		public void PortRange ()
 		{
 		{
 			for (int i = 0; i < 65536; i++) {
 			for (int i = 0; i < 65536; i++) {
@@ -2367,7 +2500,11 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void PortBelow ()
 		public void PortBelow ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2375,7 +2512,11 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void PortAbove ()
 		public void PortAbove ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2383,7 +2524,11 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#else
 		[ExpectedException (typeof (ArgumentException))]
 		[ExpectedException (typeof (ArgumentException))]
+#endif
 		public void HostTooLong ()
 		public void HostTooLong ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2403,6 +2548,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void NoDate ()
 		public void NoDate ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2410,6 +2558,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UtcDate ()
 		public void UtcDate ()
 		{
 		{
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
 			HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
@@ -2419,6 +2570,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AddAndRemoveDate ()
 		public void AddAndRemoveDate ()
 		{
 		{
 			// Neil Armstrong set his foot on Moon
 			// Neil Armstrong set his foot on Moon
@@ -2452,6 +2606,9 @@ namespace MonoTests.System.Net
 		}
 		}
 		
 		
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		// Bug #12393
 		// Bug #12393
 		public void TestIPv6Host ()
 		public void TestIPv6Host ()
 		{
 		{
@@ -2483,6 +2640,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AllowReadStreamBuffering ()
 		public void AllowReadStreamBuffering ()
 		{
 		{
 			var hr = WebRequest.CreateHttp ("http://www.google.com");
 			var hr = WebRequest.CreateHttp ("http://www.google.com");
@@ -2680,6 +2840,9 @@ namespace MonoTests.System.Net
 #endif
 #endif
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CookieContainerTest ()
 		public void CookieContainerTest ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2761,10 +2924,12 @@ namespace MonoTests.System.Net
 	}
 	}
 
 
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpRequestStreamTest
 	public class HttpRequestStreamTest
 	{
 	{
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginRead ()
 		public void BeginRead ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2820,6 +2985,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanRead ()
 		public void CanRead ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2842,6 +3010,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanSeek ()
 		public void CanSeek ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2864,6 +3035,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #324182
 		[Test] // bug #324182
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanTimeout ()
 		public void CanTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2886,6 +3060,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanWrite ()
 		public void CanWrite ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2908,6 +3085,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read ()
 		public void Read ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2935,6 +3115,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadByte ()
 		public void ReadByte ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2961,6 +3144,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadTimeout ()
 		public void ReadTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -2983,6 +3169,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Seek ()
 		public void Seek ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3009,6 +3198,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Buffer_Null ()
 		public void Write_Buffer_Null ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3035,6 +3227,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Count_Negative ()
 		public void Write_Count_Negative ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3063,6 +3258,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Count_Overflow ()
 		public void Write_Count_Overflow ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3091,6 +3289,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Offset_Negative ()
 		public void Write_Offset_Negative ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3119,6 +3320,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Offset_Overflow ()
 		public void Write_Offset_Overflow ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3147,6 +3351,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write_Request_Aborted ()
 		public void Write_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3202,6 +3409,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void WriteByte_Request_Aborted ()
 		public void WriteByte_Request_Aborted ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3229,6 +3439,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void WriteTimeout ()
 		public void WriteTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -3251,6 +3464,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		// Bug6737
 		// Bug6737
 		// This test is supposed to fail prior to .NET 4.0
 		// This test is supposed to fail prior to .NET 4.0
 		public void Post_EmptyRequestStream ()
 		public void Post_EmptyRequestStream ()

+ 90 - 2
mcs/class/System/Test/System.Net/HttpWebResponseTest.cs

@@ -21,10 +21,12 @@ using NUnit.Framework;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpWebResponseTest
 	public class HttpWebResponseTest
 	{
 	{
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CharacterSet_Disposed ()
 		public void CharacterSet_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -53,6 +55,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Close_Disposed ()
 		public void Close_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -72,6 +77,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ContentEncoding_Disposed ()
 		public void ContentEncoding_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -100,6 +108,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ContentLength_Disposed ()
 		public void ContentLength_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -120,6 +131,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ContentType_Disposed ()
 		public void ContentType_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -148,6 +162,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Cookies_Disposed ()
 		public void Cookies_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -186,6 +203,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetResponseHeader_Disposed ()
 		public void GetResponseHeader_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -214,6 +234,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void GetResponseStream_Disposed ()
 		public void GetResponseStream_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -242,6 +265,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Headers_Disposed ()
 		public void Headers_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -269,6 +295,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void LastModified_Disposed ()
 		public void LastModified_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -297,6 +326,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Method_Disposed ()
 		public void Method_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -325,6 +357,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ProtocolVersion_Disposed ()
 		public void ProtocolVersion_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -353,6 +388,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ResponseUri_Disposed ()
 		public void ResponseUri_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -381,6 +419,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Server_Disposed ()
 		public void Server_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -409,6 +450,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void StatusCode_Disposed ()
 		public void StatusCode_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -429,6 +473,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void StatusDescription_Disposed ()
 		public void StatusDescription_Disposed ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -477,10 +524,12 @@ namespace MonoTests.System.Net
 	}
 	}
 
 
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class HttpResponseStreamTest
 	public class HttpResponseStreamTest
 	{
 	{
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginRead_Buffer_Null ()
 		public void BeginRead_Buffer_Null ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -530,6 +579,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void BeginWrite ()
 		public void BeginWrite ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -590,6 +642,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanSeek ()
 		public void CanSeek ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -617,6 +672,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test] // bug #324182
 		[Test] // bug #324182
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanTimeout ()
 		public void CanTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -644,6 +702,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void CanWrite ()
 		public void CanWrite ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -671,6 +732,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read ()
 		public void Read ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -708,6 +772,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read_Buffer_Null ()
 		public void Read_Buffer_Null ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -757,6 +824,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read_Count_Negative ()
 		public void Read_Count_Negative ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -807,6 +877,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read_Count_Overflow ()
 		public void Read_Count_Overflow ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -857,6 +930,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read_Offset_Negative ()
 		public void Read_Offset_Negative ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -907,6 +983,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Read_Offset_Overflow ()
 		public void Read_Offset_Overflow ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -1021,6 +1100,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void ReadTimeout ()
 		public void ReadTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -1048,6 +1130,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void Write ()
 		public void Write ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
@@ -1080,6 +1165,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void WriteTimeout ()
 		public void WriteTimeout ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();

+ 43 - 38
mcs/class/System/Test/System.Net/ServicePointTest.cs

@@ -13,7 +13,7 @@ using System;
 using System.Collections;
 using System.Collections;
 using System.IO;
 using System.IO;
 using System.Net;
 using System.Net;
-using System.Reflection;
+using System.Reflection;
 using System.Threading;
 using System.Threading;
 
 
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
@@ -54,13 +54,13 @@ public class ServicePointTest
 		HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
 		HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://www.google.com");
 		HttpWebResponse res = (HttpWebResponse) req.GetResponse ();			
 		HttpWebResponse res = (HttpWebResponse) req.GetResponse ();			
 		
 		
-#if FOUND_SOME_OTHER_URL
-		// URL is no longer found, disabled the test until a more reliable URL is found :P
+#if FOUND_SOME_OTHER_URL
+		// URL is no longer found, disabled the test until a more reliable URL is found :P
 		//WriteServicePoint ("google after getting a response", google);
 		//WriteServicePoint ("google after getting a response", google);
 		ServicePoint google2 = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com/dilbert.html"));
 		ServicePoint google2 = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com/dilbert.html"));
 		Assert.AreEqual (google, google2, "#equals");
 		Assert.AreEqual (google, google2, "#equals");
 		res.Close ();
 		res.Close ();
-#endif
+#endif
 		
 		
 		// in both instances property CurrentConnections is 0 according to ms.net.
 		// in both instances property CurrentConnections is 0 according to ms.net.
 		// let's see what it says when we do async operations...
 		// let's see what it says when we do async operations...
@@ -87,8 +87,8 @@ public class ServicePointTest
 		//Console.WriteLine ("ContentLength: " + res2.ContentLength);
 		//Console.WriteLine ("ContentLength: " + res2.ContentLength);
 		res2.Close ();
 		res2.Close ();
 		
 		
-		ServicePoint sp2;
-#if FOUND_SOME_OTHER_URL
+		ServicePoint sp2;
+#if FOUND_SOME_OTHER_URL
 		// unless of course some buffering is taking place.. let's check
 		// unless of course some buffering is taking place.. let's check
 		Uri uri2 = new Uri ("http://freedesktop.org/Software/pkgconfig/releases/pkgconfig-0.15.0.tar.gz");
 		Uri uri2 = new Uri ("http://freedesktop.org/Software/pkgconfig/releases/pkgconfig-0.15.0.tar.gz");
 		sp2 = ServicePointManager.FindServicePoint (uri2);
 		sp2 = ServicePointManager.FindServicePoint (uri2);
@@ -102,7 +102,7 @@ public class ServicePointTest
 		// and so it shows
 		// and so it shows
 		//Console.WriteLine ("ContentLength: " + res2.ContentLength);
 		//Console.WriteLine ("ContentLength: " + res2.ContentLength);
 		res2.Close ();
 		res2.Close ();
-#endif
+#endif
 		
 		
 		
 		
 		// what's the limit of the cache?
 		// what's the limit of the cache?
@@ -154,7 +154,7 @@ public class ServicePointTest
 
 
 	[Test]
 	[Test]
 	[Category ("InetAccess")]
 	[Category ("InetAccess")]
-	[Category ("AndroidNotWorking")] // #A1 fails
+	[Category ("AndroidNotWorking")] // #A1 fails
 	public void EndPointBind ()
 	public void EndPointBind ()
 	{
 	{
 		Uri uri = new Uri ("http://www.go-mono.com/");
 		Uri uri = new Uri ("http://www.go-mono.com/");
@@ -189,6 +189,10 @@ public class ServicePointTest
 	}
 	}
 
 
 	[Test] //Covers #19823
 	[Test] //Covers #19823
+#if FEATURE_NO_BSD_SOCKETS
+	// This test uses HttpWebRequest
+	[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 	public void CloseConnectionGroupConcurency ()
 	public void CloseConnectionGroupConcurency ()
 	{
 	{
 		// Try with multiple service points
 		// Try with multiple service points
@@ -206,36 +210,37 @@ public class ServicePointTest
 		}
 		}
 	}
 	}
 
 
-
-	[Test]
-	public void DnsRefreshTimeout ()
-	{
-		const int dnsRefreshTimeout = 2000;
-
-		ServicePoint sp;
-		IPHostEntry host0, host1, host2;
-		Uri uri;
-		PropertyInfo hostEntryProperty;
-
-		ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
-
-		uri = new Uri ("http://localhost/");
-		sp = ServicePointManager.FindServicePoint (uri);
-
-		hostEntryProperty = typeof (ServicePoint).GetProperty ("HostEntry", BindingFlags.NonPublic | BindingFlags.Instance);
-
-		host0 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
-		host1 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
-
-		Assert.AreSame (host0, host1, "HostEntry should result in the same IPHostEntry object.");
-
-		Thread.Sleep (dnsRefreshTimeout * 2);
-		host2 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
-
-		Assert.AreNotSame(host0, host2, "HostEntry should result in a new IPHostEntry " +
-				"object when DnsRefreshTimeout is reached.");
-	}
-
+
+	[Test]
+	[Category ("RequiresBSDSockets")] // Tests internals, so it doesn't make sense to assert that PlatformNotSupportedExceptions are thrown.
+	public void DnsRefreshTimeout ()
+	{
+		const int dnsRefreshTimeout = 2000;
+
+		ServicePoint sp;
+		IPHostEntry host0, host1, host2;
+		Uri uri;
+		PropertyInfo hostEntryProperty;
+
+		ServicePointManager.DnsRefreshTimeout = dnsRefreshTimeout;
+
+		uri = new Uri ("http://localhost/");
+		sp = ServicePointManager.FindServicePoint (uri);
+
+		hostEntryProperty = typeof (ServicePoint).GetProperty ("HostEntry", BindingFlags.NonPublic | BindingFlags.Instance);
+
+		host0 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
+		host1 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
+
+		Assert.AreSame (host0, host1, "HostEntry should result in the same IPHostEntry object.");
+
+		Thread.Sleep (dnsRefreshTimeout * 2);
+		host2 = hostEntryProperty.GetValue (sp, null) as IPHostEntry;
+
+		Assert.AreNotSame(host0, host2, "HostEntry should result in a new IPHostEntry " +
+				"object when DnsRefreshTimeout is reached.");
+	}
+
 // Debug code not used now, but could be useful later
 // Debug code not used now, but could be useful later
 /*
 /*
 	private void WriteServicePoint (string label, ServicePoint sp)
 	private void WriteServicePoint (string label, ServicePoint sp)

+ 22 - 1
mcs/class/System/Test/System.Net/WebClientTest.cs

@@ -21,7 +21,6 @@ using MonoTests.Helpers;
 namespace MonoTests.System.Net
 namespace MonoTests.System.Net
 {
 {
 	[TestFixture]
 	[TestFixture]
-	[Category ("RequiresBSDSockets")]
 	public class WebClientTest
 	public class WebClientTest
 	{
 	{
 		private string _tempFolder;
 		private string _tempFolder;
@@ -1419,6 +1418,9 @@ namespace MonoTests.System.Net
 
 
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadValues1 ()
 		public void UploadValues1 ()
 		{
 		{
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
 			IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
@@ -1669,6 +1671,10 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		// We throw a PlatformNotSupportedException deeper, which is caught and re-thrown as WebException
+		[ExpectedException (typeof (WebException))]
+#endif
 		public void GetWebRequestOverriding ()
 		public void GetWebRequestOverriding ()
 		{
 		{
 			GetWebRequestOverridingTestClass testObject = new GetWebRequestOverridingTestClass ();
 			GetWebRequestOverridingTestClass testObject = new GetWebRequestOverridingTestClass ();
@@ -1783,6 +1789,9 @@ namespace MonoTests.System.Net
 		 
 		 
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadStringAsyncCancelEvent ()
 		public void UploadStringAsyncCancelEvent ()
 		{
 		{
 			UploadAsyncCancelEventTest (9301, (webClient, uri, cancelEvent) =>
 			UploadAsyncCancelEventTest (9301, (webClient, uri, cancelEvent) =>
@@ -1800,6 +1809,9 @@ namespace MonoTests.System.Net
 
 
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadDataAsyncCancelEvent ()
 		public void UploadDataAsyncCancelEvent ()
 		{
 		{
 			UploadAsyncCancelEventTest (9302, (webClient, uri, cancelEvent) =>
 			UploadAsyncCancelEventTest (9302, (webClient, uri, cancelEvent) =>
@@ -1816,6 +1828,9 @@ namespace MonoTests.System.Net
 		
 		
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadValuesAsyncCancelEvent ()
 		public void UploadValuesAsyncCancelEvent ()
 		{
 		{
 			UploadAsyncCancelEventTest (9303, (webClient, uri, cancelEvent) =>
 			UploadAsyncCancelEventTest (9303, (webClient, uri, cancelEvent) =>
@@ -1832,6 +1847,9 @@ namespace MonoTests.System.Net
 
 
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadFileAsyncCancelEvent ()
 		public void UploadFileAsyncCancelEvent ()
 		{
 		{
 			UploadAsyncCancelEventTest (9304,(webClient, uri, cancelEvent) =>
 			UploadAsyncCancelEventTest (9304,(webClient, uri, cancelEvent) =>
@@ -1851,6 +1869,9 @@ namespace MonoTests.System.Net
 
 
 		[Test]
 		[Test]
 		[Category ("AndroidNotWorking")] // Test suite hangs if the tests runs as part of the entire BCL suite. Works when only this fixture is ran
 		[Category ("AndroidNotWorking")] // Test suite hangs if the tests runs as part of the entire BCL suite. Works when only this fixture is ran
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void UploadFileAsyncContentType ()
 		public void UploadFileAsyncContentType ()
 		{
 		{
 			var port = NetworkHelpers.FindFreePort ();
 			var port = NetworkHelpers.FindFreePort ();

+ 6 - 0
mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs

@@ -124,6 +124,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void AddRestricted ()
 		public void AddRestricted ()
 		{
 		{
 			col = CreateRestrictedHeaders ();
 			col = CreateRestrictedHeaders ();
@@ -236,6 +239,9 @@ namespace MonoTests.System.Net
 		}
 		}
 
 
 		[Test]
 		[Test]
+#if FEATURE_NO_BSD_SOCKETS
+		[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 		public void RemoveRestricted ()
 		public void RemoveRestricted ()
 		{
 		{
 			col = CreateRestrictedHeaders ();
 			col = CreateRestrictedHeaders ();

+ 69 - 53
mcs/class/System/Test/System.Net/WebRequestTest.cs

@@ -11,10 +11,10 @@
 //
 //
 
 
 using NUnit.Framework;
 using NUnit.Framework;
-using MonoTests.Helpers;
+using MonoTests.Helpers;
 using System;
 using System;
 using System.Net;
 using System.Net;
-using System.Threading;
+using System.Threading;
 using System.Collections;
 using System.Collections;
 using System.Runtime.Serialization;
 using System.Runtime.Serialization;
 using Socks = System.Net.Sockets;
 using Socks = System.Net.Sockets;
@@ -193,6 +193,9 @@ namespace MonoTests.System.Net {
 		}
 		}
 
 
 	[Test]
 	[Test]
+#if FEATURE_NO_BSD_SOCKETS
+	[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 	public void All ()
 	public void All ()
 	{
 	{
 		WebRequest req = WebRequest.Create ("http://www.contoso.com");
 		WebRequest req = WebRequest.Create ("http://www.contoso.com");
@@ -264,6 +267,9 @@ namespace MonoTests.System.Net {
 	}
 	}
 
 
 	[Test]
 	[Test]
+#if FEATURE_NO_BSD_SOCKETS
+	[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
 	public void DefaultWebProxy ()
 	public void DefaultWebProxy ()
 	{
 	{
 		WebProxy proxy = new WebProxy ("proxy.intern.com", 83);
 		WebProxy proxy = new WebProxy ("proxy.intern.com", 83);
@@ -318,14 +324,18 @@ namespace MonoTests.System.Net {
 	}
 	}
 
 
 	[Test] //BNC#323452
 	[Test] //BNC#323452
-	// Throws exception with Status == Timeout. The same code behaves as the test expects when run from a regular app.
-	// Might be an issue with the test suite. To investigate.
-	[Category("AndroidNotWorking")] 
+	// Throws exception with Status == Timeout. The same code behaves as the test expects when run from a regular app.
+	// Might be an issue with the test suite. To investigate.
+	[Category("AndroidNotWorking")] 
 	public void TestFailedConnection ()
 	public void TestFailedConnection ()
 	{
 	{
 		try {
 		try {
 			WebRequest.Create ("http://127.0.0.1:0/non-existant.txt").GetResponse ();
 			WebRequest.Create ("http://127.0.0.1:0/non-existant.txt").GetResponse ();
 			Assert.Fail ("Should have raised an exception");
 			Assert.Fail ("Should have raised an exception");
+#if FEATURE_NO_BSD_SOCKETS
+		} catch (PlatformNotSupportedException) {
+			// Expected
+#endif
 		} catch (Exception e) {
 		} catch (Exception e) {
 			Assert.IsTrue (e is WebException, "Got " + e.GetType ().Name + ": " + e.Message);
 			Assert.IsTrue (e is WebException, "Got " + e.GetType ().Name + ": " + e.Message);
 			//#if NET_2_0 e.Message == "Unable to connect to the remote server"
 			//#if NET_2_0 e.Message == "Unable to connect to the remote server"
@@ -342,7 +352,7 @@ namespace MonoTests.System.Net {
 	}
 	}
 
 
 	[Test] //BNC#323452
 	[Test] //BNC#323452
-	[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
+	[Category ("AndroidNotWorking")] // Fails when ran as part of the entire BCL test suite. Works when only this fixture is ran
 	public void TestFailedResolution ()
 	public void TestFailedResolution ()
 	{
 	{
 		try {
 		try {
@@ -359,6 +369,10 @@ namespace MonoTests.System.Net {
 				Assert.Ignore ("Misbehaving DNS server.");
 				Assert.Ignore ("Misbehaving DNS server.");
 
 
 			Assert.Fail ("Should have raised an exception");
 			Assert.Fail ("Should have raised an exception");
+#if FEATURE_NO_BSD_SOCKETS
+		} catch (PlatformNotSupportedException) {
+			// Expected
+#endif
 		} catch (Exception e) {
 		} catch (Exception e) {
 			Assert.IsTrue (e is WebException);
 			Assert.IsTrue (e is WebException);
 			//#if NET_2_0 e.Message == "The underlying connection was closed: The remote name could not be resolved."
 			//#if NET_2_0 e.Message == "The underlying connection was closed: The remote name could not be resolved."
@@ -412,53 +426,55 @@ namespace MonoTests.System.Net {
 	{
 	{
 		internal TestWebRequest3 () { }
 		internal TestWebRequest3 () { }
 	}
 	}
-
-	[Test] // Covers #41477
-	[Category ("RequiresBSDSockets")]
-	public void TestReceiveCancelation ()
-	{
-		var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
-
-		HttpListener listener = new HttpListener ();
-		listener.Prefixes.Add (uri);
-		listener.Start ();
-
-		try {
-			for (var i = 0; i < 10; i++) {
-				var request = WebRequest.CreateHttp (uri);
-				request.Method = "GET";
-
-				var tokenSource = new CancellationTokenSource ();
-				tokenSource.Token.Register(() => request.Abort ());
-
-				var responseTask = request.GetResponseAsync ();
-
-				var context = listener.GetContext ();
-				byte[] outBuffer = new byte[8 * 1024];
-				context.Response.OutputStream.WriteAsync (outBuffer, 0, outBuffer.Length);
-
-				Assert.IsTrue (responseTask.Wait (1000), "Timeout #1");
-
-				WebResponse response = responseTask.Result;
-				var stream = response.GetResponseStream ();
-
-				byte[] buffer = new byte[8 * 1024];
-				var taskRead = stream.ReadAsync (buffer, 0, buffer.Length, tokenSource.Token);
-
-				tokenSource.Cancel ();
-
-				Assert.IsTrue (taskRead.Wait (1000), "Timeout #2");
-
-				var byteRead = taskRead.Result;
-			}
-		} catch (AggregateException ex) {
-			var webEx = ex.InnerException as WebException;
-			Assert.IsNotNull(webEx, "Inner exception is not a WebException");
-			Assert.AreEqual (webEx.Status, WebExceptionStatus.RequestCanceled);
-		}
-
-		listener.Close ();
-	}
+
+	[Test] // Covers #41477
+#if FEATURE_NO_BSD_SOCKETS
+	[ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+	public void TestReceiveCancelation ()
+	{
+		var uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
+
+		HttpListener listener = new HttpListener ();
+		listener.Prefixes.Add (uri);
+		listener.Start ();
+
+		try {
+			for (var i = 0; i < 10; i++) {
+				var request = WebRequest.CreateHttp (uri);
+				request.Method = "GET";
+
+				var tokenSource = new CancellationTokenSource ();
+				tokenSource.Token.Register(() => request.Abort ());
+
+				var responseTask = request.GetResponseAsync ();
+
+				var context = listener.GetContext ();
+				byte[] outBuffer = new byte[8 * 1024];
+				context.Response.OutputStream.WriteAsync (outBuffer, 0, outBuffer.Length);
+
+				Assert.IsTrue (responseTask.Wait (1000), "Timeout #1");
+
+				WebResponse response = responseTask.Result;
+				var stream = response.GetResponseStream ();
+
+				byte[] buffer = new byte[8 * 1024];
+				var taskRead = stream.ReadAsync (buffer, 0, buffer.Length, tokenSource.Token);
+
+				tokenSource.Cancel ();
+
+				Assert.IsTrue (taskRead.Wait (1000), "Timeout #2");
+
+				var byteRead = taskRead.Result;
+			}
+		} catch (AggregateException ex) {
+			var webEx = ex.InnerException as WebException;
+			Assert.IsNotNull(webEx, "Inner exception is not a WebException");
+			Assert.AreEqual (webEx.Status, WebExceptionStatus.RequestCanceled);
+		}
+
+		listener.Close ();
+	}
 }
 }
 
 
 }
 }

+ 1 - 0
mcs/class/System/mobile_System.dll.sources

@@ -173,6 +173,7 @@ System.Net/HttpListenerContext.cs
 System.Net/HttpListenerPrefixCollection.cs
 System.Net/HttpListenerPrefixCollection.cs
 System.Net/HttpListenerRequest.cs
 System.Net/HttpListenerRequest.cs
 System.Net/HttpListenerResponse.cs
 System.Net/HttpListenerResponse.cs
+System.Net/HttpListenerResponseHelper.cs
 System.Net/HttpListenerTimeoutManager.cs
 System.Net/HttpListenerTimeoutManager.cs
 System.Net/HttpRequestCreator.cs
 System.Net/HttpRequestCreator.cs
 System.Net/HttpStreamAsyncResult.cs
 System.Net/HttpStreamAsyncResult.cs

+ 27 - 0
mcs/class/System/monotouch_watch_System.dll.exclude.sources

@@ -0,0 +1,27 @@
+Mono.Net.Security/LegacySslStream.cs
+Mono.Net.Security/MonoLegacyTlsProvider.cs
+System.Net.Mail/SmtpClient.cs
+System.Net.Sockets/TcpClient.cs
+System.Net.Sockets/TcpListener.cs
+System.Net.Sockets/UdpClient.cs
+System.Net.WebSockets/ClientWebSocket.cs
+System.Net/ChunkedInputStream.cs
+System.Net/EndPointListener.cs
+System.Net/EndPointManager.cs
+System.Net/FtpAsyncResult.cs
+System.Net/FtpDataStream.cs
+System.Net/FtpRequestCreator.cs
+System.Net/FtpRequestCreator.cs
+System.Net/FtpStatus.cs
+System.Net/FtpWebRequest.cs
+System.Net/FtpWebResponse.cs
+System.Net/HttpConnection.cs
+System.Net/HttpListener.cs
+System.Net/HttpListenerContext.cs
+System.Net/HttpListenerPrefixCollection.cs
+System.Net/HttpListenerRequest.cs
+System.Net/HttpListenerResponse.cs
+System.Net/HttpWebRequest.cs
+System.Net/HttpWebResponse.cs
+System.Net/ListenerAsyncResult.cs
+System.Net/ResponseStream.cs

+ 15 - 0
mcs/class/System/monotouch_watch_System.dll.sources

@@ -1 +1,16 @@
 #include monotouch_System.dll.sources
 #include monotouch_System.dll.sources
+System.Net.Mail/SmtpClient.platformnotsupported.cs
+System.Net.Sockets/TcpClient.platformnotsupported.cs
+System.Net.Sockets/TcpListener.platformnotsupported.cs
+System.Net.Sockets/UdpClient.platformnotsupported.cs
+System.Net.WebSockets/ClientWebSocket.platformnotsupported.cs
+System.Net/FtpRequestCreator.platformnotsupported.cs
+System.Net/FtpWebRequest.platformnotsupported.cs
+System.Net/FtpWebResponse.platformnotsupported.cs
+System.Net/HttpListener.platformnotsupported.cs
+System.Net/HttpListenerContext.platformnotsupported.cs
+System.Net/HttpListenerPrefixCollection.platformnotsupported.cs
+System.Net/HttpListenerRequest.platformnotsupported.cs
+System.Net/HttpListenerResponse.platformnotsupported.cs
+System.Net/HttpWebRequest.platformnotsupported.cs
+System.Net/HttpWebResponse.platformnotsupported.cs

Некоторые файлы не были показаны из-за большого количества измененных файлов