2002-06-24 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Mon, 24 Jun 2002 09:41:09 +0000 (09:41 -0000)
committerDick Porter <dick@acm.org>
Mon, 24 Jun 2002 09:41:09 +0000 (09:41 -0000)
* Socket.cs: Make SetSocketOption cope with boolean values (they
are passed as objects, not the ints the runtime was expecting)

svn path=/trunk/mcs/; revision=5427

mcs/class/System/System.Net.Sockets/ChangeLog
mcs/class/System/System.Net.Sockets/Socket.cs

index 79a31237bf122359cb10c6472cca5738c4fac907..71576113b37c9f98ea2119fe3643f767d7614ec9 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-24  Dick Porter  <dick@ximian.com>
+
+       * Socket.cs: Make SetSocketOption cope with boolean values (they
+       are passed as objects, not the ints the runtime was expecting)
+
 2002-05-17  Lawrence Pit <loz@cable.a2000.nl>
        * TcpListener.cs: Renamed LocalEndPoint to LocalEndpoint
        * NetworkStream.cs, UdpClient.cs and TcpClient.cs: modified disposable 
index 890cdc47d59e802058a8e51c3fc29ee8b0bb28b8..3f1785381fd055be925146a3210330e7dba33772 100644 (file)
@@ -896,8 +896,28 @@ namespace System.Net.Sockets
                                throw new ArgumentNullException();
                        }
                        
-                       SetSocketOption_internal(socket, level, name,
-                                                opt_value, null, 0);
+                       /* Passing a bool as the third parameter to
+                        * SetSocketOption causes this overload to be
+                        * used when in fact we want to pass the value
+                        * to the runtime as an int.
+                        */
+                       if(opt_value is System.Boolean) {
+                               bool bool_val=(bool)opt_value;
+                               
+                               /* Stupid casting rules :-( */
+                               if(bool_val==true) {
+                                       SetSocketOption_internal(socket, level,
+                                                                name, null,
+                                                                null, 1);
+                               } else {
+                                       SetSocketOption_internal(socket, level,
+                                                                name, null,
+                                                                null, 0);
+                               }
+                       } else {
+                               SetSocketOption_internal(socket, level, name,
+                                                        opt_value, null, 0);
+                       }
                }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]