Socket.io can't get rid of "io is not defined" error

Can't get socket.io to work and always got error ReferenceError: io is not defined

Server code:

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

var io = socket.listen(app);

app.get('/room', function (req, res) {
res.render('room.ejs')
});

io.sockets.on('connection', function (client) { 
    console.log('Client connected...')
    });

app.listen(process.env.PORT || 17336);

Client code:

<script src="localhost:17336/socket.io/socket.io.js"></script>
<script>var socket = io.connect('http://localhost:17336')</script>   

Here's directory structure of my site:
(making it in WebMatrix)

Site
  |__iisnode
  |__node_modules
       |__.bin
       |__ejs
       |__express 
       |__socket.io
  |__public
  |__views
       |__room.ejs (Client code is here)
  |__favicon.ico
  |__robots.txt
  |__server.js (Server code is here)
  |__web.config

This is because localhost:17336/socket.io/socket.io.js is not available. I am guessing your socket.io server is not starting because you are using Express 2.0 syntax, but have Express 3.0 installed.

Express 3 requires that you instantiate a http.Server to attach socket.io to first. Here is how I do it :

var express = require('express');
var app = express()
  , http = require('http')
  , server = http.createServer(app)
  , io = require('socket.io').listen(server);

I don't know much about socket.io, but taking the error message literally, it appears that localhost:17336/socket.io/socket.io.js is not importing the symbol io into the client. Then the next line is impossible because io is not yet defined.

You should open that socket.io.js file in your browser and read it, to make sure it really is defining a variable called io.