title: Return alive Hosts with aynchronous functions
body: <p>I'm trying to retrieve a list of alive hosts via Javascript. The function for that matter should be implemented like the following:</p>
  
  <pre><code>//getState returns an array of states (up or down) for all the given list of ip addresses
  var host_states = getState(list_of_ip_addresses);
  </code></pre>
  
  <p>In order to check if a host is alive or not, I'm using websockets:</p>
  
  <pre><code>var ip = "ws://"+current_ip;
  var s = new WebSocket(ip);
  //if the onerror is called, state host as up
  s.onerror= function(){/*state host as up*/};
  //after a delay, automatically state host as down
  setTimeout(function(){/*state host as down*/},delay);
  </code></pre>
  
  <p>Since the the state of the host is determined via callbacks (asynchronous), how do I return the state of one or many hosts, like in the function above? (Without polling)</p>