title: http.createServer(app) v. http.Server(app)
body: <p>On the socket.io web page, <code>Get Started: Chat application</code>, located here:</p>
  
  <p><a href="http://socket.io/get-started/chat/">http://socket.io/get-started/chat/</a></p>
  
  <p>there is this code:</p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  </code></pre>
  
  <p>which could be rewritten a little more clearly like this:</p>
  
  <pre><code>var express = require('express');
  var http = require('http');
  
  var app = express();
  var server = http.Server(app);
  </code></pre>
  
  <p>The socket.io example uses http.Server() to create a server.  Yet, the express docs for <a href="http://expressjs.com/api.html#app.listen">app.listen()</a> show an example where the server is created using <code>http.createServer(app)</code>:</p>
  
  <blockquote>
    <p><strong>app.listen()</strong><br>
    Bind and listen for connections on the given host and port. This
    method is identical to node's http.Server#listen().</p>
  
  <pre><code>var express = require('express');  
  var app = express();  
  app.listen(3000);
  </code></pre>
    
    <p>The app returned by express() is in fact a JavaScript Function,
    designed to be passed to node's HTTP servers as a callback to handle
    requests. This allows you to provide both HTTP and HTTPS versions of
    your app with the same codebase easily, as the app does not inherit
    from these (it is simply a callback):</p>
  
  <pre><code>var express = require('express');
  var https = require('https');
  var http = require('http');
  var app = express();
  
  http.createServer(app).listen(80);
  https.createServer(options, app).listen(443);
  </code></pre>
    
    <p>The app.listen() method is a convenience method for the following (if
    you wish to use HTTPS or provide both, use the technique above):</p>
  
  <pre><code>app.listen = function(){
    var server = http.createServer(this);
    return server.listen.apply(server, arguments);
  };
  </code></pre>
  </blockquote>
  
  <p>What's the difference between <code>http.createServer(app)</code> and <code>http.Server(app)</code>??  The http docs are no help.</p>