title: Calculating packet travel time in JavaScript
body: <p>My server broadcasts a packet to a browser client every now and then.</p>
  
  <p>Is there any way to figure out how long it took from the packet from:</p>
  
  <pre><code>server --&gt; client
  </code></pre>
  
  <p>I'm trying to time something, so ideally my JavaScript function would be like:</p>
  
  <pre><code>var travelTime = {amount of time it took packet to get to me};
  setTimeout('myFunction()', 3000 + travelTime);
  </code></pre>
  
  <p>Also, I'm not requesting this packet so I can't log the send time, and log the recieve time on the client side. This packet request is not bi-directional, as I establish a socket with the server and the server has the ability to just fire me a packet.</p>
  
  <p>Any advice is appriciated!</p>
  
  <p>EDIT: comet-style connection</p>