From 8fca1a368c242cf570848f86b068294430ef0f89 Mon Sep 17 00:00:00 2001 From: Dick Porter Date: Mon, 24 Jun 2002 09:41:09 +0000 Subject: [PATCH] 2002-06-24 Dick Porter * 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 | 5 ++++ mcs/class/System/System.Net.Sockets/Socket.cs | 24 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/System.Net.Sockets/ChangeLog b/mcs/class/System/System.Net.Sockets/ChangeLog index 79a31237bf1..71576113b37 100644 --- a/mcs/class/System/System.Net.Sockets/ChangeLog +++ b/mcs/class/System/System.Net.Sockets/ChangeLog @@ -1,3 +1,8 @@ +2002-06-24 Dick Porter + + * 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 * TcpListener.cs: Renamed LocalEndPoint to LocalEndpoint * NetworkStream.cs, UdpClient.cs and TcpClient.cs: modified disposable diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs index 890cdc47d59..3f1785381fd 100644 --- a/mcs/class/System/System.Net.Sockets/Socket.cs +++ b/mcs/class/System/System.Net.Sockets/Socket.cs @@ -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)] -- 2.25.1