aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-13 23:37:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-13 23:37:05 +0000
commit4d426fc2e03078d583d5d573d4863415c3e3eb8d (patch)
tree12f8cb073100eda38adf86d58a2cd9ed96c7c5b7 /test/socket
parentd739458b7142a97b35707623390ea36c9b22b536 (diff)
downloadruby-4d426fc2e03078d583d5d573d4863415c3e3eb8d.tar.gz
test_basicsocket.rb: do not hardcode port number
* test/socket/test_basicsocket.rb (socks): use dynamically chosen port number, and remove never used argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_basicsocket.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/socket/test_basicsocket.rb b/test/socket/test_basicsocket.rb
index 5c8cffe451..c37f312984 100644
--- a/test/socket/test_basicsocket.rb
+++ b/test/socket/test_basicsocket.rb
@@ -86,11 +86,11 @@ class TestSocket_BasicSocket < Test::Unit::TestCase
end
end
- def socks(port)
- sserv = TCPServer.new(12345)
+ def socks
+ sserv = TCPServer.new(0)
ssock = nil
t = Thread.new { ssock = sserv.accept }
- csock = TCPSocket.new('localhost', 12345)
+ csock = TCPSocket.new('localhost', sserv.addr[1])
t.join
yield sserv, ssock, csock
ensure
@@ -100,7 +100,7 @@ class TestSocket_BasicSocket < Test::Unit::TestCase
end
def test_close_read
- socks(12345) do |sserv, ssock, csock|
+ socks do |sserv, ssock, csock|
# close_read makes subsequent reads raise IOError
csock.close_read
@@ -116,7 +116,7 @@ class TestSocket_BasicSocket < Test::Unit::TestCase
end
def test_close_write
- socks(12345) do |sserv, ssock, csock|
+ socks do |sserv, ssock, csock|
# close_write makes subsequent writes raise IOError
csock.close_write