summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 05:16:47 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 05:16:47 +0000
commit990cb712b48613df544524b06e642a7e530e7f59 (patch)
treed6f351e637d3019e9d7de7513fb02fd65f4168ec /test/socket
parent919bb8e5585984400e32aac9d4a158562b56c9a6 (diff)
merge revision(s) 53557,53561: [Backport #11958]
* ext/socket/option.c (check_size): extract a macro to check binary data size, with a consistent message. * ext/socket/option.c (sockopt_byte): fix error message, sizeof(int) differs from sizeof(unsigned char) in general. * 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/branches/ruby_2_3@54355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_sockopt.rb6
1 files changed, 6 insertions, 0 deletions
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