title: Connecting to HTML5 Websocket
body: <p>I'm a bit confused about HTML5 Websockets. I've looked at numerous tutorials out there and a lot of them have different variations of connecting using different ports. What do these ports mean?</p>
  
  <p><a href="http://www.adobe.com/devnet/html5/articles/real-time-data-exchange-in-html5-with-websockets.html">Adobe</a> for instance, uses this:</p>
  
  <pre><code>new WebSocket('ws://localhost:1740');
  </code></pre>
  
  <p>Then another <a href="http://www.websocket.org/aboutwebsocket.html">tutorial</a> has this where no ports are required: </p>
  
  <pre><code>new WebSocket("ws://www.websockets.org");
  </code></pre>
  
  <p>And finally a third tutorial has a port, but it's completely different: </p>
  
  <pre><code>new WebSocket("ws://localhost:8080/echo");
  </code></pre>
  
  <p>My question would be, why do these vary? How do I know which ports to connect to? Also, I've attempted to do my own connection:</p>
  
  <pre><code>var ws = new WebSocket("ws://test.ontarget-network.com/");
  </code></pre>
  
  <p>But I get the following error: <code>Unexpected response code: 200</code></p>
  
  <p>I've tested around and tried connecting to various other "ports" (not knowing what I'm doing obviously, typing in random numbers) and this error would disappear, however, my code </p>
  
  <pre><code>ws.onopen = function(){
     alert("Connection Established");
  };
  </code></pre>
  
  <p>would not execute. </p>
  
  <p>I'm trying to fully understand HTML5's Websockets API so I can experiment and create more dynamic applications. Thanks for the help.</p>