From 7f247b9d0c652cfd88c4d4ebbc1a6587e48cad83 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 27 Feb 2009 13:10:25 +0000 Subject: [PATCH] add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/socket/test_socket.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index dc7a6e1125..d6a70dd40f 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -209,7 +209,40 @@ class TestSocket < Test::Unit::TestCase ensure servers.each {|s| s.close if !s.closed? } end + end + def test_accept_loop_multi_port + servers = [] + begin + servers = Socket.tcp_server_sockets(0) + port = servers[0].local_address.ip_port + servers2 = Socket.tcp_server_sockets(0) + servers.concat servers2 + port2 = servers2[0].local_address.ip_port + + Socket.tcp("localhost", port) {|s1| + Socket.accept_loop(servers) {|s2, client_ai| + begin + assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack) + ensure + s2.close + end + break + } + } + Socket.tcp("localhost", port2) {|s1| + Socket.accept_loop(servers) {|s2, client_ai| + begin + assert_equal(s1.local_address.ip_unpack, client_ai.ip_unpack) + ensure + s2.close + end + break + } + } + ensure + servers.each {|s| s.close if !s.closed? } + end end def test_udp_server