Hi,
  Please correct if my understanding is wrong for the below code:-
Code to check if a port is free or not.

def port_available?(port)
  begin
    TCPServer.new('localhost', port).close
    rescue
      return false
    else
     return true
  end
end

Port will be closed. While closing if an exception occurs, it
returns false. Else true.

Thanks

-- 
Posted via http://www.ruby-forum.com/.