Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use socket.io with Express 3
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var server = app.listen(3000);
var io = require('socket.io').listen(server);
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
console.log("Express server listening on port 3000");
@itsjustcon

This comment has been minimized.

Show comment
Hide comment
@itsjustcon

itsjustcon Mar 28, 2013

Worked like a charm. Thanks!

Worked like a charm. Thanks!

@mohsen1

This comment has been minimized.

Show comment
Hide comment
@mohsen1

mohsen1 Apr 20, 2013

Thank you, it was helpful. It's number one result for "using express 3 and socket.io".

mohsen1 commented Apr 20, 2013

Thank you, it was helpful. It's number one result for "using express 3 and socket.io".

@justaurelia

This comment has been minimized.

Show comment
Hide comment

Thanks !!!!

@fesja

This comment has been minimized.

Show comment
Hide comment
@fesja

fesja Sep 1, 2013

thanks!

fesja commented Sep 1, 2013

thanks!

@satbirdd

This comment has been minimized.

Show comment
Hide comment
@satbirdd

satbirdd Oct 4, 2013

the 7th line"http = require('http');", ti's neccesary? i did't see you use http

satbirdd commented Oct 4, 2013

the 7th line"http = require('http');", ti's neccesary? i did't see you use http

@dfkuro

This comment has been minimized.

Show comment
Hide comment
@dfkuro

dfkuro Dec 10, 2013

Thanks, it works.

dfkuro commented Dec 10, 2013

Thanks, it works.

@thomasbrueggemann

This comment has been minimized.

Show comment
Hide comment
@thomasbrueggemann

thomasbrueggemann Dec 23, 2013

Perfect, thank you!

Perfect, thank you!

@fmoris

This comment has been minimized.

Show comment
Hide comment

fmoris commented Dec 27, 2013

Thanks!

@drjova

This comment has been minimized.

Show comment
Hide comment

drjova commented Mar 12, 2014

Thanks!

@DrDyne

This comment has been minimized.

Show comment
Hide comment
@DrDyne

DrDyne Mar 16, 2014

Thanks a lot !

DrDyne commented Mar 16, 2014

Thanks a lot !

@pomerus

This comment has been minimized.

Show comment
Hide comment
@pomerus

pomerus Apr 13, 2014

Thank you !

pomerus commented Apr 13, 2014

Thank you !

@quinvit

This comment has been minimized.

Show comment
Hide comment
@quinvit

quinvit May 2, 2014

Thank you !

quinvit commented May 2, 2014

Thank you !

@vishakashoka

This comment has been minimized.

Show comment
Hide comment
@vishakashoka

vishakashoka Jun 27, 2014

You Rock! Thank you

You Rock! Thank you

@asccigcc

This comment has been minimized.

Show comment
Hide comment
@asccigcc

asccigcc Jul 22, 2014

Thank you!

Thank you!

@heanfig

This comment has been minimized.

Show comment
Hide comment
@heanfig

heanfig Aug 18, 2014

Excelent, Thank You :)

heanfig commented Aug 18, 2014

Excelent, Thank You :)

@scottglenblanch

This comment has been minimized.

Show comment
Hide comment

Thanks a ton!

@mackeyguenther

This comment has been minimized.

Show comment
Hide comment

👍

@titechnologies

This comment has been minimized.

Show comment
Hide comment
@titechnologies

titechnologies Jan 12, 2015

Good one... Thanks alot!!!

Good one... Thanks alot!!!

@mikes16

This comment has been minimized.

Show comment
Hide comment
@mikes16

mikes16 Mar 11, 2015

Niceeee!! Thank you!! ;)

mikes16 commented Mar 11, 2015

Niceeee!! Thank you!! ;)

@bsautron

This comment has been minimized.

Show comment
Hide comment
@peheje

This comment has been minimized.

Show comment
Hide comment
@peheje

peheje Jan 18, 2016

Works like a charm. Stackoverflow posts failed to help me, but this works like a charm.

peheje commented Jan 18, 2016

Works like a charm. Stackoverflow posts failed to help me, but this works like a charm.

@jpna

This comment has been minimized.

Show comment
Hide comment
@jpna

jpna Jan 10, 2017

Very helpful, thank you!

jpna commented Jan 10, 2017

Very helpful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment