//socket学习
var socket = require(./socket.js); //引入socket.js文件(该文件可以通过node命令:npm install socket.io获取直接添加到node_models文件目录中)
//2.
var port = narmallizePort(process.env.PORT||8000);//设置端口号
app.set('port',port);
//3.服务器监听
var http = require('http');
var app = express();//XXX
var server = http.createServer(app);
server.listen(port,function(){
console.log('Server Listening on port:'+port +'success!');
});
server.on('error',onError);
server.on('listening',onListening);
//4.获取参数
req.query.XXX || req.param('XXX') // get请求
req.body.XXX || req.param('XXX') //post请求
nodeJS 之 socket.io
最新推荐文章于 2024-09-29 01:54:58 发布