Browse Source

2004-05-13 Dick Porter <[email protected]>

	* UdpClient.cs:
	* TcpClient.cs: Public API fixes

svn path=/trunk/mcs/; revision=27286
Dick Porter 21 years ago
parent
commit
0937ade06a

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

@@ -1,3 +1,8 @@
+2004-05-13  Dick Porter  <[email protected]>
+
+	* UdpClient.cs: 
+	* TcpClient.cs: Public API fixes
+
 2004-05-07  Gonzalo Paniagua Javier <[email protected]>
 
 	* Socket.cs: fixed Connect for non-blocking sockets. Closes bug #58169.

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

@@ -53,6 +53,19 @@ namespace System.Net.Sockets
 			client.Bind(new IPEndPoint(IPAddress.Any, 0));
 		}
 	
+#if NET_1_1
+		public TcpClient (AddressFamily family)
+		{
+			if (family != AddressFamily.InterNetwork &&
+			    family != AddressFamily.InterNetworkV6) {
+				throw new ArgumentException ("Family must be InterNetwork or InterNetworkV6", "family");
+			}
+			
+			Init (family);
+			client.Bind (new IPEndPoint (IPAddress.Any, 0));
+		}
+#endif
+		
 		/// <summary>
 		/// Constructs a new TcpClient with a specified local endpoint.
 		/// Use this if you want to have your connections originating

+ 66 - 3
mcs/class/System/System.Net.Sockets/UdpClient.cs

@@ -24,6 +24,7 @@ namespace System.Net.Sockets
 		{
 		}
 
+#if NET_1_1
 		public UdpClient(AddressFamily family)
 		{
 			if(family != AddressFamily.InterNetwork && family != AddressFamily.InterNetwork)
@@ -32,6 +33,7 @@ namespace System.Net.Sockets
 			this.family = family;
 			InitSocket (null);
 		}
+#endif
 
 		public UdpClient (int port)
 		{
@@ -53,7 +55,27 @@ namespace System.Net.Sockets
 
 			InitSocket (localEP);
 		}
-
+
+#if NET_1_1
+		public UdpClient (int port, AddressFamily family)
+		{
+			if (family != AddressFamily.InterNetwork &&
+			    family != AddressFamily.InterNetworkV6) {
+				throw new ArgumentException ("Family must be InterNetwork or InterNetworkV6", "family");
+			}
+			
+			if (port < IPEndPoint.MinPort ||
+			    port > IPEndPoint.MaxPort) {
+				throw new ArgumentOutOfRangeException ("port");
+			}
+			
+			this.family = family;
+
+			IPEndPoint localEP = new IPEndPoint (IPAddress.Any, port);
+			InitSocket (localEP);
+		}
+#endif
+		
 		public UdpClient (string hostname, int port)
 		{
 			if (hostname == null)
@@ -150,7 +172,31 @@ namespace System.Net.Sockets
 					new IPv6MulticastOption (multicastAddr));
 #endif
 		}
-
+
+#if NET_1_1
+		public void DropMulticastGroup (IPAddress multicastAddr,
+						int ifindex)
+		{
+			CheckDisposed ();
+
+			/* LAMESPEC: exceptions haven't been specified
+			 * for this overload.
+			 */
+			if (multicastAddr == null) {
+				throw new ArgumentNullException ("multicastAddr");
+			}
+
+			/* Does this overload only apply to IPv6?
+			 * Only the IPv6MulticastOption has an
+			 * ifindex-using constructor.  The MS docs
+			 * don't say.
+			 */
+			if (family == AddressFamily.InterNetworkV6) {
+				socket.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.DropMembership, new IPv6MulticastOption (multicastAddr, ifindex));
+			}
+		}
+#endif
+		
 		public void JoinMulticastGroup (IPAddress multicastAddr)
 		{
 			CheckDisposed ();
@@ -164,7 +210,24 @@ namespace System.Net.Sockets
 					new IPv6MulticastOption (multicastAddr));
 #endif
 		}
-
+
+#if NET_1_1
+		public void JoinMulticastGroup (int ifindex,
+						IPAddress multicastAddr)
+		{
+			CheckDisposed ();
+
+			/* Does this overload only apply to IPv6?
+			 * Only the IPv6MulticastOption has an
+			 * ifindex-using constructor.  The MS docs
+			 * don't say.
+			 */
+			if (family == AddressFamily.InterNetworkV6) {
+				socket.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption (multicastAddr, ifindex));
+			}
+		}
+#endif
+		
 		public void JoinMulticastGroup (IPAddress multicastAddr, int timeToLive)
 		{
 			CheckDisposed ();