From 6308dd132e9ad5df50ae24641f70db2aad797183 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 17 Jan 2016 06:31:36 +0000 Subject: option.c: single byte boolean * ext/socket/option.c (sockopt_bool): relax boolean size to be one too not only sizeof(int). Winsock getsockopt() returns a single byte as a boolean socket option. [ruby-core:72730] [Bug #11958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/socket/test_sockopt.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/socket/test_sockopt.rb b/test/socket/test_sockopt.rb index 0a2937e4fe..f38ac2a891 100644 --- a/test/socket/test_sockopt.rb +++ b/test/socket/test_sockopt.rb @@ -25,6 +25,12 @@ class TestSocketOption < Test::Unit::TestCase assert_equal(true, opt.bool) opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 2) assert_equal(true, opt.bool) + Socket.open(:INET, :STREAM) {|s| + s.setsockopt(Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)) + assert_equal(true, s.getsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE).bool) + s.setsockopt(Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false)) + assert_equal(false, s.getsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE).bool) + } end def test_ipv4_multicast_loop -- cgit v1.2.3