Socket.io using node.js with no express at all? Socket.io using node.js with no express at all? express express

Socket.io using node.js with no express at all?


Make sure you installed socket.io by npm and have socket.io client as well. For sure you can use socket.io client on CDN:

<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>

For the server side, socket.io should bootstrap the app instance but not http.E.g:

var http = require('http');var socket = require('socket.io');function server()...app = http.createServer(server);io = socket(app);app.listen(80);

By default, they use port 80 so that in client-side they just point to localhost like this var socket = io('http://localhost');. If you want to use other port, you must change in io client-side instantiation too.

var socket = io('http://localhost:1337')