constapp=require('express')()constserver=require('http').Server(app);constio=require('socket.io')(server)server.listen(80)// 警告:app.listen(80)在这里没起作用,可能有端口被占用情况app.get('/',(req,res)=>{res.sendFile(__dirname+'/index.html')})io.on('connection',(socket)=>{socket.emit('news',{hello:'world'}socket.on('my other event',(data)=>{console.log(data) })})