我似乎无法让这个工作;为什么不会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)