1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<!DOCTYPE html> <html> <head> <title>socket.io</title> <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost:8081'); socket.on('news', function (msg) { console.log(msg); socket.emit('my other event', msg + ' back'); }); </script> </head> <body> <p>hello socket.io.</p> </body> </html>