mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0f82f65cee
commit
7f247b9d0c
1 changed files with 33 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue