これを機能させることができないようです。なぜThread.start
起動しないのですか?
# encoding: utf-8
require 'socket'
print "choose host: "
host = gets.chomp
print "choose starting port: "
sport = gets.to_i
print "choose ending port: "
eport = gets.to_i
def scanner (sport, eport, host)
while sport <= eport
begin
s = TCPSocket.new(host, sport)
if s
puts "Port #{sport} is open!"
end
rescue
puts "Port #{sport} is closed!"
end
sport += 1
end
end
Thread.start([scanner]sport, eport, host)