Sha256: f8f65695fbd99c96403721d729416e4a720202cb12ae1c966f70cbd362a70329
Contents?: true
Size: 813 Bytes
Versions: 51
Compression:
Stored size: 813 Bytes
Contents
# frozen_string_literal: true module Nonnative class Port def initialize(process) @process = process @timeout = Nonnative::Timeout.new(process.timeout) end def open? timeout.perform do open_socket true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH sleep_interval retry end end def closed? timeout.perform do open_socket raise Nonnative::Error rescue Nonnative::Error sleep_interval retry rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET true end end private attr_reader :process, :timeout def open_socket TCPSocket.new('0.0.0.0', process.port).close end def sleep_interval sleep 0.01 end end end
Version data entries
51 entries across 51 versions & 1 rubygems