def ping(host = @host)
super(host)
bool = false
udp = UDPSocket.open
array = []
if @bind_host
udp.bind(@bind_host, @bind_port)
end
start_time = Time.now
begin
Timeout.timeout(@timeout){
udp.connect(host, @port)
udp.send(@data, 0)
array = udp.recvfrom(MAX_DATA)
}
rescue Errno::ECONNREFUSED, Errno::ECONNRESET => err
if @@service_check
@exception = err
else
bool = true
end
rescue Exception => err
@exception = err
else
if array[0] == @data
bool = true
end
ensure
udp.close if udp
end
@duration = Time.now - start_time if bool
bool
end