summaryrefslogtreecommitdiff
path: root/lib/custodian/multiping.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/custodian/multiping.rb')
-rw-r--r--lib/custodian/multiping.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/custodian/multiping.rb b/lib/custodian/multiping.rb
index 64c3573..a39e81b 100644
--- a/lib/custodian/multiping.rb
+++ b/lib/custodian/multiping.rb
@@ -1,7 +1,7 @@
require 'getoptlong'
require 'socket'
-
+require 'timeout'
class MultiPing
@@ -24,10 +24,17 @@ class MultiPing
res = nil
begin
- Socket.getaddrinfo(hostname, 'echo').each do |a|
- res = a[3]
+ timeout( 4 ) do
+
+ begin
+ Socket.getaddrinfo(hostname, 'echo').each do |a|
+ res = a[3]
+ end
+ rescue SocketError
+ end
end
- rescue SocketError
+ rescue Timeout::Error => e
+ resolved = nil
end
res