更新时间:2022-01-28 07:34:42
用于从http.Server
继承的Express应用程序,它们不再这样做,而这正是close
方法的来源.而是在您的srv
实例上调用close()
.您可能通常会看到此代码写为:
Express applications used to inherit from http.Server
, which they no longer do, and that's where the close
method came from. Instead, call close()
on your srv
instance. You may commonly see this code written as:
var app = express.createServer();
var srv = require('http').createServer(app);
srv.listen(port);
根据app.listen()
的文档:
绑定并侦听给定主机和端口上的连接,此方法与节点的
http.Server#listen()
相同.