Express.js and Socket.io

I'm building a chat system using Express and Socket.io. I would like to understand which are the functionality of these two frameworks in this type of project, because consulting the APIs I got confused.

What are the differences bewteen this:

USING EXPRESS 3/4

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

server.listen(80);

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

and this:

USING WITH THE EXPRESS FRAMEWORK

var app = require('express').createServer();
var io = require('socket.io')(app);

app.listen(80);

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

I'm a lot confused, so I hope that somebody will explain this question.

If you are using Express 3 or 4 use the first one, if you're using an older version of Express, use the second one.