Class: Nonnative::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/nonnative/port.rb

Instance Method Summary collapse

Constructor Details

#initialize(process) ⇒ Port

Returns a new instance of Port.



5
6
7
8
# File 'lib/nonnative/port.rb', line 5

def initialize(process)
  @process = process
  @timeout = Nonnative::Timeout.new(process.timeout)
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nonnative/port.rb', line 20

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

#open?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
# File 'lib/nonnative/port.rb', line 10

def open?
  timeout.perform do
    open_socket
    true
  rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
    sleep_interval
    retry
  end
end