I'm having trouble even getting the very basic socket.io sample to run. For example the first example on the welcome page of their site:
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
on the server side and
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
on the client side. If I save the server-side in a host.js
file, and the client-side in a client.htm
file, and I run npm host.js
, I get
info - socket.io started
warn - error raised: Error: listen EADDRINUSE
which is already not really expected. Then, for the client.htm
(or at least that's what I think that I'm supposed to do with it -- pasting it in a client.htm file), I only get a blank screen. Not very surprising, since it starts by including a nonexisting file /socket.io/socket.io.js
, but even changing this to host.js
(which I assume it is supposed to be) doesn't change the fact that I only get a blank screen...
I'm clueless.