Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Socket io + static file serving with connect
<!-- This should be served by your server -->
<script src="/"></script>
var socket = io.connect('http://localhost');
socket.on('news', function (data) {
socket.emit('my other event', { my: 'data' });
var connect = require('connect')
, http = require('http');
var app = connect().use(connect.static(__dirname));
var server = http.createServer(app);
var io = require('').listen(server);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment