title: WebSockets with Node.js and socket.io
body: <p>I have build a game using canvas and Javascript, and I would like to implement multiplayer functionality using WebSockets and Node.js</p>
  
  <p>I'm completely new to Node, and I have managed to get a basic web server up and running with the following code:</p>
  
  <pre><code>var http = require("http");
  
  console.log("Server started at port 8888");
  
  http.createServer(function(request, response) {
          response.writeHead(200, {"Content-Type": "text/plain"});
          response.write("Hello World");
          response.end();
  }).listen(8888);
  </code></pre>
  
  <p>It all works, I get the response of "Hello World" when I navigate to to my server IP on port 8888. My question is, is this all I need to start using WebSockets with Node? I have heard people say I still need socket.io so that Node can use sockets, but I don't know if that's just a library to help me use sockets or if Node actually can't understand sockets.</p>
  
  <p>The server basically has to keep a note of all players connected, their scores, their positions on the canvas, etc. A client will poll the server (using WebSockets) occasionally in order to get everyones positions and then update their canvas with the returned information. Would I need socket.io for this? Either way, how would I go about doing this?</p>
  
  <p>Thanks.</p>