Browse Source

2008-06-12 Stephane Delcroix <[email protected]>

	* Socket.cs: minimal changes to run in the 2.1 profile

svn path=/trunk/mcs/; revision=105690
Stephane Delcroix 17 years ago
parent
commit
49ee8b5d33

+ 4 - 0
mcs/class/System/System.Net.Sockets/ChangeLog

@@ -1,3 +1,7 @@
+2008-06-12  Stephane Delcroix  <[email protected]>
+
+	* Socket.cs: minimal changes to run in the 2.1 profile
+
 2008-06-11  Stephane Delcroix  <[email protected]>
 
 	* SocketAsyncEventArgs.cs: catch SocketException in ConnectAsync

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

@@ -2044,6 +2044,22 @@ namespace System.Net.Sockets
 					throw new SocketException ((int) SocketError.AddressNotAvailable);
 			}
 
+#if NET_2_1
+			// Check for SL2.0b1 restrictions
+			// - tcp only
+			// - SiteOfOrigin
+			// - port 4502->4532 + default
+			if (protocol_type != ProtocolType.Tcp)
+				throw new SocketException ((int) SocketError.AccessDenied);
+			//FIXME: replace 80 by Application.Curent.Host.Source.Port
+			if (remote_end is IPEndPoint)
+				if (((remote_end as IPEndPoint).Port < 4502 || (remote_end as IPEndPoint).Port > 4530) && (remote_end as IPEndPoint).Port != 80)
+					throw new SocketException ((int) SocketError.AccessDenied);
+			else //unsuported endpoint type
+				throw new SocketException ((int) SocketError.AccessDenied);
+			//FIXME: check for Application.Curent.Host.Source.DnsSafeHost
+#endif
+
 #if NET_2_0
 			/* TODO: check this for the 1.1 profile too */
 			if (islistening)
@@ -2058,7 +2074,9 @@ namespace System.Net.Sockets
 				Connect_internal (socket, serial, out error);
 			} catch (ThreadAbortException) {
 				if (disposed) {
+#if !NET_2_1 //2.1 profile does not contains Thread.ResetAbort
 					Thread.ResetAbort ();
+#endif
 					error = (int) SocketError.Interrupted;
 				}
 			} finally {