code: def listening?(host, port)
        begin
          socket = TCPSocket.new(host, port)
          socket.close unless socket.nil?
          true
        rescue Errno::ECONNREFUSED, SocketError,
          Errno::EBADF,           # Windows
          Errno::EADDRNOTAVAIL    # Windows
          false
        end
      end
docs: courtesy of http://is.gd/eoYho