title: node.js: socket.io vs express.static
body: <p>I have the following server.js running:</p>
  
  <pre><code>module.exports = server;
  
  var express = require('express');
  var fs = require('fs');
  
  var server = express.createServer();    
  
  var port = 58000;
  server.listen(port);
  
  var io = require('socket.io').listen(server);
  
  server.use(express.static('/', __dirname + '/../public'));
  
  server.use(express.logger());
  
  io.on('connection', function(client){
      console.log('new client connected ' + client);
      client.on('message', function(){
          console.log('client wants something');
      });
  });
  </code></pre>
  
  <p>Simple express.static server for files in a /public subfolder, plus socket.io functionality. With this setup, any request for the 'socket.io.js' file fails, i.e.</p>
  
  <pre><code>http://localhost:58000/socket.io/socket.io.js
  </code></pre>
  
  <p>returns a 404 error (file not found). Static file server works correctly. If I simply use the 'http' module instead of 'express' (commenting out express.static and express.logger lines) socket.io.js is served correctly. How can I combine both functionalities?</p>