I have installed socket.io on my localhost and now I would view a client/server communication. I have started the server with node 'server.js'. I get this error
ERR_NAME_NOT_RESOLVED
with this simple lines of code:
SERVER:
var io = require('socket.io').listen(8080);
io.sockets.on('connection', function (socket) {
console.log('emit...');
socket.emit('ping', { message: 'Hello from server ' + Date.now() });
socket.on('pong', function (data) {
console.log(data.message);
});
});
console.log('listening on port 8080');
CLIENT:
<script type="text/javascript" src="js/socket.io.js"></script>
<script>
var socket = io.connect('http:\\192.168.1.129:8080');
socket.on('connect', function() {
socket.emit('pong',{message:"ciaooo"});
socket.on('ping', function (data) {
alert(data);
});
});
</script>
Try to replace
with