title: Why do nodejs WebSocket implementations not use net.Server?
body: <p>I am currently experiencing with Websockets.</p>
  
  <p>By reviewing some active projects/implementations like einaros/ws (and others as well) I found out that they implement the server their own. Instead of using the node net module which provides a tcp server. Is there a reason for this approach?</p>
  
  <p><a href="https://github.com/einaros/ws/blob/master/lib/WebSocketServer.js" rel="nofollow">https://github.com/einaros/ws/blob/master/lib/WebSocketServer.js</a></p>
  
  <p>Regards</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>var server = net.createServer(function(c) {
  
    c.on('data', function(data) {
      // data is a websocket fragment which has to get parsed
    });
    // transformToSingleUtfFragment is building a websocket valid
    // byte fragment which contains hello as application payload
    // and sets the right flags so the receiver knows we have a single text fragment
    c.write(transformToSingleUtfFragment('hello'));
    c.pipe(c);
  });
  server.listen(8124, function() { //'listening' listener
    console.log('server bound');
  });
  </code></pre>