Method: Portfinder::Scanner#scan

Defined in:
lib/portfinder/scanner.rb

#scan(synchronus = true, &callback) ⇒ Object

Scans host(s) according to provided specification



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/portfinder/scanner.rb', line 31

def scan synchronus = true, &callback
  @monitor.start
  if @threaded
    case @thread_for
    when :ip
      scan_threaded_ip
    when :port
      scan_threaded_port
    end

    if synchronus
      @pool.shutdown
      @monitor.stop
    elsif callback
      @pool.shutdown(false) do
        callback.call
        @monitor
      end
    end
  else
    synchronus_scan
  end
end