Class: PortScanner::TCP
- Inherits:
-
Object
- Object
- PortScanner::TCP
- Defined in:
- lib/port_scanner.rb
Instance Method Summary collapse
Instance Method Details
#scan(ip, port) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/port_scanner.rb', line 8 def scan( ip, port ) begin Timeout::timeout(1) do begin s = TCPSocket.new(ip, port) s.close return true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH return false end end rescue Timeout::Error end return false end |