node.js: How to run express and on the same port

The express web server and are very handy modules for node.js. Either of the modules can listen to the same port, because the modules use different protocols. But how can this be configured? The ‘How to use” section of the webpage has the solution, even though it is hard to find. The following code shows how to create a simple web server and a websocket communication on the same port.

var express = require("express");
var io = require('')
var port = 80;
var htmlDir = "./client/"

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

app.configure(function () {

This entry was posted in Development, Node.js and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s