express监听端口有以下两种方法
var express = require(‘express‘);
var app = express();
app.listen(3000);
var http = require(‘http‘),
express = require(‘express‘);
var app = express();
http.createServer(app).listen(3000);
两种方法其实是一样的,看看express的源码
app.listen = function(){
var server = http.createServer(this);
return server.listen.apply(server, arguments);
};
一目了然了
Express直接listen()和嵌套在http上listen()的不同
原文地址:http://blog.csdn.net/crystal_tyan/article/details/43834663