diff options
author | Masaki Matsushita <glass.saga@gmail.com> | 2019-09-10 09:57:31 +0900 |
---|---|---|
committer | Masaki Matsushita <glass.saga@gmail.com> | 2019-09-10 10:10:59 +0900 |
commit | 0e9d56f5e73ed2fd8e7c858fdea7b7d5b905bb64 (patch) | |
tree | 6f6133010c44d90c82e0f3b5a53edf649e4352a5 /test/socket | |
parent | 3678c371199d9a048589bf3da37f06223912dea5 (diff) |
Support timeout for Addrinfo
Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as
a keyword argument. If getaddrinfo_a(3) is available, the timeout will be
applied for name resolution. Otherwise, it will be ignored.
Socket.tcp accepts :resolv_timeout to use this feature.
This commit is retry of 6382f5cc91ac9e36776bc854632d9a1237250da7.
Test was failed on Solaris machines which don't have "http" in
/etc/services. In this commit, use "ssh" instead.
Diffstat (limited to 'test/socket')
-rw-r--r-- | test/socket/test_addrinfo.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb index a06f3eb451..68341c2148 100644 --- a/test/socket/test_addrinfo.rb +++ b/test/socket/test_addrinfo.rb @@ -688,5 +688,10 @@ class TestSocketAddrinfo < Test::Unit::TestCase assert_equal(ai1.canonname, ai2.canonname) end + def test_addrinfo_timeout + ai = Addrinfo.getaddrinfo("localhost", "ssh", Socket::PF_INET, Socket::SOCK_STREAM, timeout: 1).fetch(0) + assert_equal(6, ai.protocol) + assert_equal(22, ai.ip_port) + end end end |