Socket.io实际上是WebSocket的父集,Socket.io封装了WebSocket和轮询等方法 首先得在你的项目中安装socket.io $ npm install socket.io 服务端代码: var app=require('http').createServer() var io=require('socket.io')(app) var PORT =5555; var clientCount=0; app.listen(PORT) io.on('connection',f